1  /-
  2  Copyright (c) 2019 Jeremy Avigad. All rights reserved.
  3  Released under Apache 2.0 license as described in the file LICENSE.
  4  Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov
  5  -/
  6  
  7  import analysis.asymptotics analysis.calculus.tangent_cone
src         └──────────────────┘ └────────────────────────────┘
  8  
  9  /-!
 10  # The Fréchet derivative
 11  
 12  Let `E` and `F` be normed spaces, `f : E → F`, and `f' : E →L[𝕜] F` a
 13  continuous 𝕜-linear map, where `𝕜` is a non-discrete normed field. Then
 14  
 15    `has_fderiv_within_at f f' s x`
 16  
 17  says that `f` has derivative `f'` at `x`, where the domain of interest
 18  is restricted to `s`. We also have
 19  
 20    `has_fderiv_at f f' x := has_fderiv_within_at f f' x univ`
 21  
 22  ## Main results
 23  
 24  In addition to the definition and basic properties of the derivative, this file contains the
 25  usual formulas (and existence assertions) for the derivative of
 26  * constants
 27  * the identity
 28  * bounded linear maps
 29  * bounded bilinear maps
 30  * sum of two functions
 31  * multiplication of a function by a scalar constant
 32  * negative of a function
 33  * subtraction of two functions
 34  * multiplication of a function by a scalar function
 35  * multiplication of two scalar functions
 36  * composition of functions (the chain rule)
 37  
 38  For most binary operations we also define `const_op` and `op_const` theorems for the cases when
 39  the first or second argument is a constant. This makes writing chains of `has_deriv_at`'s easier,
 40  and they more frequently lead to the desired result.
 41  
 42  One can also interpret the derivative of a function `f : 𝕜 → E` as an element of `E` (by identifying
 43  a linear function from `𝕜` to `E` with its value at `1`). Results on the Fréchet derivative are
 44  translated to this more elementary point of view on the derivative in the file `deriv.lean`. The
 45  derivative of polynomials is handled there, as it is naturally one-dimensional.
 46  
 47  ## Implementation details
 48  
 49  The derivative is defined in terms of the `is_o` relation, but also
 50  characterized in terms of the `tendsto` relation.
 51  
 52  We also introduce predicates `differentiable_within_at 𝕜 f s x` (where `𝕜` is the base field,
 53  `f` the function to be differentiated, `x` the point at which the derivative is asserted to exist,
 54  and `s` the set along which the derivative is defined), as well as `differentiable_at 𝕜 f x`,
 55  `differentiable_on 𝕜 f s` and `differentiable 𝕜 f` to express the existence of a derivative.
 56  
 57  To be able to compute with derivatives, we write `fderiv_within 𝕜 f s x` and `fderiv 𝕜 f x`
 58  for some choice of a derivative if it exists, and the zero function otherwise. This choice only
 59  behaves well along sets for which the derivative is unique, i.e., those for which the tangent
 60  directions span a dense subset of the whole space. The predicates `unique_diff_within_at s x` and
 61  `unique_diff_on s`, defined in `tangent_cone.lean` express this property. We prove that indeed
 62  they imply the uniqueness of the derivative. This is satisfied for open subsets, and in particular
 63  for `univ`. This uniqueness only holds when the field is non-discrete, which we request at the very
 64  beginning: otherwise, a derivative can be defined, but it has no interesting properties whatsoever.
 65  
 66  ## Tags
 67  
 68  derivative, differentiable, Fréchet, calculus
 69  
 70  -/
 71  
 72  open filter asymptotics continuous_linear_map set
 73  open_locale topological_space classical
 74  
 75  noncomputable theory
 76  
 77  set_option class.instance_max_depth 90
doc             └──────────────────────┘
 78  
 79  section
 80  
 81  variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
id                          └──────────────────────┘
src                         └──────────────────────┘
typ                         └──────────────────────┘
doc                         └──────────────────────┘
 82  variables {E : Type*} [normed_group E] [normed_space 𝕜 E]
id                          └──────────┘     └──────────┘
src                         └──────────┘     └──────────┘
typ                         └──────────┘     └──────────┘
doc                         └──────────┘     └──────────┘
 83  variables {F : Type*} [normed_group F] [normed_space 𝕜 F]
id                          └──────────┘     └──────────┘
src                         └──────────┘     └──────────┘
typ                         └──────────┘     └──────────┘
doc                         └──────────┘     └──────────┘
 84  variables {G : Type*} [normed_group G] [normed_space 𝕜 G]
id                          └──────────┘     └──────────┘
src                         └──────────┘     └──────────┘
typ                         └──────────┘     └──────────┘
doc                         └──────────┘     └──────────┘
 85  
 86  /-- A function `f` has the continuous linear map `f'` as derivative along the filter `L` if
 87  `f x' = f x + f' (x' - x) + o (x' - x)` when `x'` converges along the filter `L`. This definition
 88  is designed to be specialized for `L = 𝓝 x` (in `has_fderiv_at`), giving rise to the usual notion
 89  of Fréchet derivative, and for `L = nhds_within x s` (in `has_fderiv_within_at`), giving rise to
 90  the notion of Fréchet derivative along the set `s`. -/
 91  def has_fderiv_at_filter (f : E → F) (f' : E →L[𝕜] F) (x : E) (L : filter E) :=
id                                             └─┘               └────┘ 
src                                               └─┘                  └────┘
typ                                            └─┘               └────┘ 
doc                                               └─┘ 
 92  is_o (λ x', f x' - f x - f' (x' - x)) (λ x', x' - x) L
id   └──┘    └┘   └┘     └┘  └┘        └┘  └┘    
src  └──┘                                         
typ  └──┘    └┘   └┘     └┘  └┘        └┘  └┘    
doc  └──┘
 93  
 94  /-- A function `f` has the continuous linear map `f'` as derivative at `x` within a set `s` if
 95  `f x' = f x + f' (x' - x) + o (x' - x)` when `x'` tends to `x` inside `s`. -/
 96  def has_fderiv_within_at (f : E → F) (f' : E →L[𝕜] F) (s : set E) (x : E) :=
id                                             └─┘        └─┘        
src                                               └─┘          └─┘
typ                                            └─┘        └─┘        
doc                                               └─┘ 
 97  has_fderiv_at_filter f f' x (nhds_within x s)
id   └──────────────────┘  └┘   └─────────┘  
src  └──────────────────┘         └─────────┘
typ  └──────────────────┘  └┘   └─────────┘  
doc  └──────────────────┘         └─────────┘
 98  
 99  /-- A function `f` has the continuous linear map `f'` as derivative at `x` if
100  `f x' = f x + f' (x' - x) + o (x' - x)` when `x'` tends to `x`. -/
101  def has_fderiv_at (f : E → F) (f' : E →L[𝕜] F) (x : E) :=
id                                      └─┘        
src                                        └─┘ 
typ                                     └─┘        
doc                                        └─┘ 
102  has_fderiv_at_filter f f' x (𝓝 x)
id   └──────────────────┘  └┘    
src  └──────────────────┘         
typ  └──────────────────┘  └┘    
doc  └──────────────────┘         
103  
104  variables (𝕜)
105  
106  /-- A function `f` is differentiable at a point `x` within a set `s` if it admits a derivative
107  there (possibly non-unique). -/
108  def differentiable_within_at (f : E → F) (s : set E) (x : E) :=
id                                               └─┘        
src                                                └─┘
typ                                              └─┘        
109  ∃f' : E →L[𝕜] F, has_fderiv_within_at f f' s x
id         └─┘  └──────────────────┘  └┘  
src         └─┘    └──────────────────┘
typ        └─┘  └──────────────────┘  └┘  
doc          └─┘     └──────────────────┘
110  
111  /-- A function `f` is differentiable at a point `x` if it admits a derivative there (possibly
112  non-unique). -/
113  def differentiable_at (f : E → F) (x : E) :=
id                                        
typ                                       
114  ∃f' : E →L[𝕜] F, has_fderiv_at f f' x
id         └─┘  └───────────┘  └┘ 
src         └─┘    └───────────┘
typ        └─┘  └───────────┘  └┘ 
doc          └─┘     └───────────┘
115  
116  /-- If `f` has a derivative at `x` within `s`, then `fderiv_within 𝕜 f s x` is such a derivative.
117  Otherwise, it is set to `0`. -/
118  def fderiv_within (f : E → F) (s : set E) (x : E) : E →L[𝕜] F :=
id                                    └─┘             └─┘ 
src                                     └─┘                └─┘ 
typ                                   └─┘             └─┘ 
doc                                                        └─┘ 
119  if h : ∃f', has_fderiv_within_at f f' s x then classical.some h else 0
id   └┘     └┘ └──────────────────┘  └┘        └────────────┘       
src  └┘        └──────────────────┘               └────────────┘        
typ  └┘     └┘ └──────────────────┘  └┘        └────────────┘       
doc              └──────────────────┘
120  
121  /-- If `f` has a derivative at `x`, then `fderiv 𝕜 f x` is such a derivative. Otherwise, it is
122  set to `0`. -/
123  def fderiv (f : E → F) (x : E) : E →L[𝕜] F :=
id                                  └─┘ 
src                                     └─┘ 
typ                                 └─┘ 
doc                                     └─┘ 
124  if h : ∃f', has_fderiv_at f f' x then classical.some h else 0
id   └┘     └┘ └───────────┘  └┘       └────────────┘       
src  └┘        └───────────┘             └────────────┘
typ  └┘     └┘ └───────────┘  └┘       └────────────┘       
doc              └───────────┘
125  
126  /-- `differentiable_on 𝕜 f s` means that `f` is differentiable within `s` at any point of `s`. -/
127  def differentiable_on (f : E → F) (s : set E) :=
id                                        └─┘ 
src                                         └─┘
typ                                       └─┘ 
128  ∀x ∈ s, differentiable_within_at 𝕜 f s x
id         └──────────────────────┘    
src         └──────────────────────┘
typ        └──────────────────────┘    
doc          └──────────────────────┘
129  
130  /-- `differentiable 𝕜 f` means that `f` is differentiable at any point. -/
131  def differentiable (f : E → F) :=
id                              
typ                             
132  ∀x, differentiable_at 𝕜 f x
id      └───────────────┘   
src      └───────────────┘
typ     └───────────────┘   
doc      └───────────────┘
133  
134  variables {𝕜}
135  variables {f f₀ f₁ g : E → F}
136  variables {f' f₀' f₁' g' : E →L[𝕜] F}
id                                └─┘ 
src                               └─┘ 
typ                               └─┘ 
doc                               └─┘ 
137  variables (e : E →L[𝕜] F)
id                    └─┘ 
src                   └─┘ 
typ                   └─┘ 
doc                   └─┘ 
138  variables {x : E}
139  variables {s t : set E}
id                    └─┘
src                   └─┘
typ                   └─┘
140  variables {L L₁ L₂ : filter E}
id                        └────┘
src                       └────┘
typ                       └────┘
141  
142  lemma fderiv_within_zero_of_not_differentiable_within_at
143    (h : ¬ differentiable_within_at 𝕜 f s x) : fderiv_within 𝕜 f s x = 0 :=
id           └──────────────────────┘        └───────────┘     
src          └──────────────────────┘            └───────────┘         
typ          └──────────────────────┘        └───────────┘     
doc           └──────────────────────┘            └───────────┘
144  have ¬ ∃ f', has_fderiv_within_at f f' s x, from h,
id          └┘ └──────────────────┘  └┘         
src            └──────────────────┘
typ         └┘ └──────────────────┘  └┘         
doc               └──────────────────┘
145  by simp [fderiv_within, this]
id            └───────────┘  └──┘
src     └────┘└───────────┘└┘    └─
typ     └────┘└───────────┘└┘└──┘└─
doc     └────┘└───────────┘└┘    └─
txt     └────┘             └┘    └─
par     └────┘             └┘    └─
pid                      └┘    
st     └───────────────────────────
146  
src  
typ  
doc  
txt  
par  
pid  
st   
147  lemma fderiv_zero_of_not_differentiable_at (h : ¬ differentiable_at 𝕜 f x) : fderiv 𝕜 f x = 0 :=
id                                                    └───────────────┘       └────┘    
src                                                   └───────────────┘          └────┘       
typ                                                   └───────────────┘       └────┘    
doc                                                    └───────────────┘          └────┘
148  have ¬ ∃ f', has_fderiv_at f f' x, from h,
id          └┘ └───────────┘  └┘        
src            └───────────┘
typ         └┘ └───────────┘  └┘        
doc               └───────────┘
149  by simp [fderiv, this]
id            └────┘  └──┘
src     └────┘└────┘└┘    └─
typ     └────┘└────┘└┘└──┘└─
doc     └────┘└────┘└┘    └─
txt     └────┘      └┘    └─
par     └────┘      └┘    └─
pid               └┘    
st     └────────────────────
150  
src  
typ  
doc  
txt  
par  
pid  
st   
151  section derivative_uniqueness
152  /- In this section, we discuss the uniqueness of the derivative.
153  We prove that the definitions `unique_diff_within_at` and `unique_diff_on` indeed imply the
154  uniqueness of the derivative. -/
155  
156  /-- If a function f has a derivative f' at x, a rescaled version of f around x converges to f', i.e.,
157  `n (f (x + (1/n) v) - f x)` converges to `f' v`. More generally, if `c n` tends to infinity and
158  `c n * d n` tends to `v`, then `c n * (f (x + d n) - f x)` tends to `f' v`. This lemma expresses
159  this fact, for functions having a derivative within a set. Its specific formulation is useful for
160  tangent cone related discussions. -/
161  theorem has_fderiv_within_at.lim (h : has_fderiv_within_at f f' s x) {α : Type*} (l : filter α)
id                                         └──────────────────┘  └┘                     └────┘ 
src                                        └──────────────────┘                            └────┘
typ                                        └──────────────────┘  └┘                     └────┘ 
doc                                        └──────────────────┘
162    {c : α → 𝕜} {d : α → E} {v : E} (dtop : ∀ᶠ n in l, x + d n ∈ s)
id                                        └┘  └┘       
src                                            └┘   └┘          
typ                                       └┘  └┘       
doc                                            └┘   └┘  
163    (clim : tendsto (λ n, ∥c n∥) l at_top)
id             └─────┘          └────┘
src            └─────┘              └────┘
typ            └─────┘          └────┘
doc            └─────┘                └────┘
164    (cdlim : tendsto (λ n, c n • d n) l (𝓝 v)) :
id              └─────┘               
src             └─────┘                    
typ             └─────┘               
doc             └─────┘                     
165    tendsto (λn, c n • (f (x + d n) - f x)) l (𝓝 (f' v)) :=
id     └─────┘                         └┘ 
src    └─────┘                                 
typ    └─────┘                         └┘ 
doc    └─────┘                                    
166  begin
st   └─────
167    have tendsto_arg : tendsto (λ n, x + d n) l (nhds_within x s),
id                        └─────┘                └─────────┘  
src    └─────────────────┘└─────┘  └──┘   └┘  └─────────┘  
typ    └─────────────────┘└─────┘  └──┘  └┘ └─────────┘
doc    └─────────────────┘└─────┘  └──┘    └┘  └─────────┘  
txt    └─────────────────┘         └──┘    └┘               
par    └─────────────────┘         └──┘    └┘               
pid    └──────────────┘└─┘         └──┘    └┘               
st   ──────────────────────────────────────────────────────────────┘└─
168    { conv in (nhds_within x s) { rw ← add_zero x },
id                └─────────┘           └──────┘ 
src      └──────┘ └─────────┘  └──┘└───┘└──────┘ 
typ      └──────┘ └─────────┘└──┘└───┘└──────┘
doc               └─────────┘
txt      └──────┘              └──┘└───┘         
par      └──────┘              └──┘└───┘         
pid          └─┘              └──────┘         └┘
st   ───┘└─────────────────────────┘└───────────────┘└┘
169      rw [nhds_within, tendsto_inf],
id           └─────────┘  └─────────┘
src      └──┘└─────────┘└┘└─────────┘
typ      └──┘└─────────┘└┘└─────────┘
doc      └──┘└─────────┘└┘           
txt      └──┘           └┘           
par      └──┘           └┘           
pid        └┘           └┘           
st   ──────────────────┘└───────────┘└──
170      split,
src      └───┘
typ      └───┘
doc      └───┘
txt      └───┘
par      └───┘
st   ────────┘└─
171      { apply tendsto_const_nhds.add (tangent_cone_at.lim_zero l clim cdlim) },
id               └────────────────────┘  └──────────────────────┘  └──┘ └───┘
src        └────┘└────────────────────┘ └──────────────────────┘          └┘
typ        └────┘└────────────────────┘ └──────────────────────┘└──┘└───┘└┘
doc        └────┘                       └──────────────────────┘          └┘
txt        └────┘                                                         └┘
par        └────┘                                                         └┘
pid                                                                      
st   ─────┘└───────────────────────────────────────────────────────────────────┘└┘
172      { rwa tendsto_principal } },
id             └───────────────┘
src        └──┘└───────────────┘
typ        └──┘└───────────────┘
doc        └──┘                 
txt        └──┘                 
par        └──┘                 
pid                            
st   ───────────────────────────┘└──┘
173    have : is_o (λ y, f y - f x - f' (y - x)) (λ y, y - x) (nhds_within x s) := h,
id            └──┘                 └┘                        └─────────┘       
src    └─────┘└──┘  └──┘           └─┘  └──┘   └┘ └─────────┘  └───┘
typ    └─────┘└──┘  └──┘    └┘    └─┘  └──┘   └┘ └─────────┘└───┘
doc    └─────┘└──┘  └──┘            └─┘  └──┘   └┘ └─────────┘  └───┘
txt    └─────┘      └──┘            └─┘  └──┘   └┘              └───┘
par    └─────┘      └──┘            └─┘  └──┘   └┘              └───┘
pid    └───┘└┘      └──┘            └─┘  └──┘   └┘              └──┘
st   ──────────────────────────────────────────────────────────────────────────────┘└─
174    have : is_o (λ n, f (x + d n) - f x - f' ((x + d n) - x)) (λ n, (x + d n)  - x) l :=
id            └──┘                          └┘                                      
src    └─────┘└──┘  └──┘      └┘            └┘  └─┘  └──┘     └─┘  └┘ └───
typ    └─────┘└──┘  └──┘      └┘   └┘      └┘  └─┘  └──┘    └─┘ └┘└───
doc    └─────┘└──┘  └──┘      └┘            └┘  └─┘  └──┘     └─┘  └┘ └───
txt    └─────┘      └──┘      └┘            └┘  └─┘  └──┘     └─┘  └┘ └───
par    └─────┘      └──┘      └┘            └┘  └─┘  └──┘     └─┘  └┘ └───
pid    └───┘└┘      └──┘      └┘            └┘  └─┘  └──┘     └─┘  └┘ └───
st   ───────────────────────────────────────────────────────────────────────────────────────
175      this.comp_tendsto tendsto_arg,
id       └───────────────┘ └─────────┘
src  ───┘└───────────────┘
typ  ───┘└───────────────┘└─────────┘
doc  ───┘                 
txt  ───┘                 
par  ───┘                 
pid  ───┘                 
st   ────────────────────────────────┘└─
176    have : is_o (λ n, f (x + d n) - f x - f' (d n)) d l := by simpa only [add_sub_cancel'],
id            └──┘                         └┘                            └─────────────┘
src    └─────┘└──┘  └──┘      └┘         └─┘  └──┘  └──────────┘└─────────────┘
typ    └─────┘└──┘  └──┘      └┘  └┘   └─┘└──┘  └──────────┘└─────────────┘
doc    └─────┘└──┘  └──┘      └┘         └─┘  └──┘  └──────────┘               
txt    └─────┘      └──┘      └┘         └─┘  └──┘  └──────────┘               
par    └─────┘      └──┘      └┘         └─┘  └──┘  └──────────┘               
pid    └───┘└┘      └──┘      └┘         └─┘  └──┘  └───────────┘               
st   ──────────────────────────────────────────────────────────┘└───────────────────────────┘└─
177    have : is_o (λn, c n • (f (x + d n) - f x - f' (d n))) (λn, c n • d n) l :=
id            └──┘                              └┘                       
src    └─────┘└──┘  └─┘         └┘         └──┘  └─┘     └┘ └───
typ    └─────┘└──┘  └─┘         └┘  └┘   └──┘  └─┘   └┘└───
doc    └─────┘└──┘  └─┘          └┘         └──┘  └─┘     └┘ └───
txt    └─────┘      └─┘          └┘         └──┘  └─┘     └┘ └───
par    └─────┘      └─┘          └┘         └──┘  └─┘     └┘ └───
pid    └───┘└┘      └─┘          └┘         └──┘  └─┘     └┘ └───
st   ──────────────────────────────────────────────────────────────────────────────
178      (is_O_refl c l).smul_is_o this,
id        └───────┘              └──┘
src  ───┘ └───────┘  └──────────┘
typ  ───┘ └───────┘└──────────┘└──┘
doc  ───┘            └──────────┘
txt  ───┘            └──────────┘
par  ───┘            └──────────┘
pid  ───┘            └──────────┘
st   ─────────────────────────────────┘└─
179    have : is_o (λn, c n • (f (x + d n) - f x - f' (d n))) (λn, (1:ℝ)) l :=
id            └──┘                              └┘                    
src    └─────┘└──┘  └─┘          └┘         └──┘  └─┘ └┘ └─┘ └───
typ    └─────┘└──┘  └─┘         └┘  └┘  └──┘  └─┘ └┘ └─┘└───
doc    └─────┘└──┘  └─┘          └┘         └──┘  └─┘ └┘ └─┘ └───
txt    └─────┘      └─┘          └┘         └──┘  └─┘ └┘ └─┘ └───
par    └─────┘      └─┘          └┘         └──┘  └─┘ └┘ └─┘ └───
pid    └───┘└┘      └─┘          └┘         └──┘  └─┘ └┘ └─┘ └───
st   ──────────────────────────────────────────────────────────────────────────
180      this.trans_is_O (is_O_one_of_tendsto ℝ cdlim),
id       └─────────────┘  └─────────────────┘   └───┘
src  ───┘└─────────────┘ └─────────────────┘      
typ  ───┘└─────────────┘ └─────────────────┘ └───┘
doc  ───┘                                         
txt  ───┘                                         
par  ───┘                                         
pid  ───┘                                         
st   ────────────────────────────────────────────────┘└─
181    have L1 : tendsto (λn, c n • (f (x + d n) - f x - f' (d n))) l (𝓝 0) :=
id               └─────┘                              └┘          
src    └────────┘└─────┘  └─┘          └┘         └──┘  └──────
typ    └────────┘└─────┘  └─┘         └┘  └┘  └──┘ └──────
doc    └────────┘└─────┘  └─┘          └┘         └──┘  └──────
txt    └────────┘         └─┘          └┘         └──┘   └──────
par    └────────┘         └─┘          └┘         └──┘   └──────
pid    └─────┘└─┘         └─┘          └┘         └──┘   └─┘└───
st   ──────────────────────────────────────────────────────────────────────────
182      (is_o_one_iff ℝ).1 this,
id        └──────────┘      └──┘
src  ───┘ └──────────┘ └──┘
typ  ───┘ └──────────┘ └──┘└──┘
doc  ───┘              └──┘
txt  ───┘              └──┘
par  ───┘              └──┘
pid  ───┘              └──┘
st   ──────────────────────────┘└─
183    have L2 : tendsto (λn, f' (c n • d n)) l (𝓝 (f' v)) :=
id               └─────┘                         └┘ 
src    └────────┘└─────┘  └─┘        └─┘       └─────
typ    └────────┘└─────┘  └─┘      └─┘   └┘└─────
doc    └────────┘└─────┘  └─┘        └─┘       └─────
txt    └────────┘         └─┘        └─┘       └─────
par    └────────┘         └─┘        └─┘       └─────
pid    └─────┘└─┘         └─┘        └─┘       └┘└───
st   ─────────────────────────────────────────────────────────
184      tendsto.comp f'.cont.continuous_at cdlim,
id       └──────────┘ └───────────────────┘ └───┘
src  ───┘└──────────┘└───────────────────┘
typ  ───┘└──────────┘└───────────────────┘└───┘
doc  ───┘                                 
txt  ───┘                                 
par  ───┘                                 
pid  ───┘                                 
st   ───────────────────────────────────────────┘└─
185    have L3 : tendsto (λn, (c n • (f (x + d n) - f x - f' (d n)) +  f' (c n • d n)))
id               └─────┘                                                      
src    └────────┘└─────┘  └─┘           └┘         └─┘ └┘        └───
typ    └────────┘└─────┘  └─┘           └┘       └─┘ └┘      └───
doc    └────────┘└─────┘  └─┘           └┘         └─┘ └┘        └───
txt    └────────┘         └─┘           └┘         └─┘ └┘        └───
par    └────────┘         └─┘           └┘         └─┘ └┘        └───
pid    └─────┘└─┘         └─┘           └┘         └─┘ └┘        └───
st   ───────────────────────────────────────────────────────────────────────────────────
186              l (𝓝 (0 + f' v)) :=
id                        └┘ 
src  ───────────┘    └┘    └─────
typ  ───────────┘   └┘ └┘└─────
doc  ───────────┘    └┘    └─────
txt  ───────────┘    └┘    └─────
par  ───────────┘    └┘    └─────
pid  ───────────┘    └┘    └┘└───
st   ────────────────────────────────
187      L1.add L2,
id       └────┘ └┘
src  ───┘└────┘
typ  ───┘└────┘└┘
doc  ───┘      
txt  ───┘      
par  ───┘      
pid  ───┘      
st   ────────────┘└─
188    have : (λn, (c n • (f (x + d n) - f x - f' (d n)) +  f' (c n • d n)))
id                                                          └┘
src    └─────┘  └─┘           └┘         └─┘ └┘        └───
typ    └─────┘  └─┘           └┘         └─┘ └┘└┘      └───
doc    └─────┘  └─┘           └┘         └─┘ └┘        └───
txt    └─────┘  └─┘           └┘         └─┘ └┘        └───
par    └─────┘  └─┘           └┘         └─┘ └┘        └───
pid    └───┘└┘  └─┘           └┘         └─┘ └┘        └───
st   ────────────────────────────────────────────────────────────────────────
189            = (λn, c n • (f (x + d n) - f x)),
id                                       
src  ─────────┘  └─┘          └┘   └┘
typ  ─────────┘  └─┘        └┘ └┘
doc  ─────────┘   └─┘          └┘   └┘
txt  ─────────┘   └─┘          └┘   └┘
par  ─────────┘   └─┘          └┘   └┘
pid  ─────────┘   └─┘          └┘   └┘
st   ──────────────────────────────────────────┘
190      by { ext n, simp [smul_add] },
id                         └──────┘
src           └───┘  └────┘└──────┘└┘
typ           └───┘  └────┘└──────┘└┘
doc           └───┘  └────┘        └┘
txt           └───┘  └────┘        └┘
par           └───┘  └────┘        └┘
pid              └┘              
st          └────┘└────────────────┘└┘
191    rwa [this, zero_add] at L3
id          └──┘  └──────┘
src    └───┘    └┘└──────┘└──────┘
typ    └───┘└──┘└┘└──────┘└──────┘
doc    └───┘    └┘        └──────┘
txt    └───┘    └┘        └──────┘
par    └───┘    └┘        └──────┘
pid       └┘    └┘        └────┘
st   ──────────┘└────────┘└─────┘
192  end
st   └─┘
193  
194  /-- `unique_diff_within_at` achieves its goal: it implies the uniqueness of the derivative. -/
195  theorem unique_diff_within_at.eq (H : unique_diff_within_at 𝕜 s x)
id                                         └───────────────────┘   
src                                        └───────────────────┘
typ                                        └───────────────────┘   
doc                                        └───────────────────┘
196    (h : has_fderiv_within_at f f' s x) (h₁ : has_fderiv_within_at f f₁' s x) : f' = f₁' :=
id          └──────────────────┘  └┘          └──────────────────┘  └─┘      └┘  └─┘
src         └──────────────────┘                 └──────────────────┘                 
typ         └──────────────────┘  └┘          └──────────────────┘  └─┘      └┘  └─┘
doc         └──────────────────┘                 └──────────────────┘
197  begin
st   └─────
198    have A : ∀y ∈ tangent_cone_at 𝕜 s x, f' y = f₁' y,
id                   └─────────────┘     └┘    └─┘
src    └───────┘ └──┘└─────────────┘          
typ    └───────┘ └──┘└─────────────┘ └┘ └─┘
doc    └───────┘ └──┘└─────────────┘           
txt    └───────┘ └──┘                          
par    └───────┘ └──┘                          
pid    └────┘└─┘ └──┘                          
st   ──────────────────────────────────────────────────┘└─
199    { rintros y ⟨c, d, dtop, clim, cdlim⟩,
src      └─────────────────────────────────┘
typ      └─────────────────────────────────┘
doc      └─────────────────────────────────┘
txt      └─────────────────────────────────┘
par      └─────────────────────────────────┘
pid             └──────────────────────────┘
st   ───┘└─────────────────────────────────┘└─
200      exact tendsto_nhds_unique (by simp) (h.lim at_top dtop clim cdlim) (h₁.lim at_top dtop clim cdlim) },
id             └─────────────────┘            └───┘                          └────┘ └────┘ └──┘ └──┘ └───┘
src      └────┘└─────────────────┘   └──┘└┘ └───┘                   └┘ └────┘└────┘             └┘
typ      └────┘└─────────────────┘   └──┘└┘ └───┘                   └┘ └────┘└────┘└──┘└──┘└───┘└┘
doc      └────┘                      └──┘└┘ └───┘                   └┘ └────┘└────┘             └┘
txt      └────┘                      └──┘└┘                         └┘                          └┘
par      └────┘                      └──┘└┘                         └┘                          └┘
pid                                 └─────┘                         └┘                          
st   ────────────────────────────────┘└───┘└───────────────────────────────────────────────────────────────┘└┘
201    have B : ∀y ∈ submodule.span 𝕜 (tangent_cone_at 𝕜 s x), f' y = f₁' y,
id                   └────────────┘    └─────────────┘      └┘     └─┘
src    └───────┘ └──┘└────────────┘  └─────────────┘           
typ    └───────┘ └──┘└────────────┘  └─────────────┘ └┘  └─┘
doc    └───────┘ └──┘└────────────┘  └─────────────┘           
txt    └───────┘ └──┘                                          
par    └───────┘ └──┘                                          
pid    └────┘└─┘ └──┘                                          
st   ─────────────────────────────────────────────────────────────────────┘└─
202    { assume y hy,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ───┘└─────────┘└─
203      apply submodule.span_induction hy,
id             └──────────────────────┘ └┘
src      └────┘└──────────────────────┘
typ      └────┘└──────────────────────┘└┘
doc      └────┘└──────────────────────┘
txt      └────┘                        
par      └────┘                        
pid                                   
st   ────────────────────────────────────┘└─
204      { exact λy hy, A y hy },
id                      
src        └────┘ └────┘    
typ        └────┘ └────┘   
doc        └────┘ └────┘    
txt        └────┘ └────┘    
par        └────┘ └────┘    
pid              └────┘    
st   ─────┘└──────────────────┘└┘
205      { simp only [continuous_linear_map.map_zero] },
id                    └────────────────────────────┘
src        └─────────┘└────────────────────────────┘└┘
typ        └─────────┘└────────────────────────────┘└┘
doc        └─────────┘                              └┘
txt        └─────────┘                              └┘
par        └─────────┘                              └┘
pid            └──┘└┘                              
st   ─────┘└─────────────────────────────────────────┘└┘
206      { simp {contextual := tt} },
id                             └┘
src        └───┘ └────────────┘└┘└┘
typ        └───┘ └────────────┘└┘└┘
doc        └───┘ └────────────┘  └┘
txt        └───┘ └────────────┘  └┘
par        └───┘ └────────────┘  └┘
pid             └────────────┘  
st   ─────┘└──────────────────────┘└┘
207      { simp {contextual := tt} } },
id                             └┘
src        └───┘ └────────────┘└┘└┘
typ        └───┘ └────────────┘└┘└┘
doc        └───┘ └────────────┘  └┘
txt        └───┘ └────────────┘  └┘
par        └───┘ └────────────┘  └┘
pid             └────────────┘  
st   ─────────────────────────────┘└──┘
208    have C : ∀y ∈ closure ((submodule.span 𝕜 (tangent_cone_at 𝕜 s x)) : set E), f' y = f₁' y,
id                   └─────┘   └────────────┘    └─────────────┘        └─┘    └┘     └─┘
src    └───────┘ └──┘└─────┘  └────────────┘  └─────────────┘   └───┘└─┘         
typ    └───────┘ └──┘└─────┘  └────────────┘  └─────────────┘└───┘└─┘ └┘  └─┘
doc    └───────┘ └──┘└─────┘  └────────────┘  └─────────────┘   └───┘            
txt    └───────┘ └──┘                                           └───┘            
par    └───────┘ └──┘                                           └───┘            
pid    └────┘└─┘ └──┘                                           └───┘            
st   ─────────────────────────────────────────────────────────────────────────────────────────┘└─
209    { assume y hy,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ───┘└─────────┘└─
210      let K := {y | f' y = f₁' y},
id                    └┘     └─┘
src      └───────┘└──┘        
typ      └───────┘└──┘└┘  └─┘ 
doc      └───────┘ └──┘        
txt      └───────┘ └──┘        
par      └───────┘ └──┘        
pid      └───┘└─┘ └──┘        
st   ──────────────────────────────┘└─
211      have : (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E) ⊆ K := B,
id               └────────────┘    └─────────────┘       └─┘        
src      └─────┘ └────────────┘  └─────────────┘   └──┘└─┘ └┘ └──┘
typ      └─────┘ └────────────┘  └─────────────┘└──┘└─┘└┘└──┘
doc      └─────┘ └────────────┘  └─────────────┘   └──┘    └┘  └──┘
txt      └─────┘                                   └──┘    └┘  └──┘
par      └─────┘                                   └──┘    └┘  └──┘
pid      └───┘└┘                                   └──┘    └┘  └──┘
st   ─────────────────────────────────────────────────────────────────────┘└─
212      have : closure (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E) ⊆ closure K :=
id                       └────────────┘    └─────────────┘       └─┘     └─────┘ 
src      └─────┘        └────────────┘  └─────────────┘   └──┘└─┘ └┘ └─────┘ └───
typ      └─────┘        └────────────┘  └─────────────┘└──┘└─┘└┘ └─────┘└───
doc      └─────┘        └────────────┘  └─────────────┘   └──┘    └┘ └─────┘ └───
txt      └─────┘                                          └──┘    └┘         └───
par      └─────┘                                          └──┘    └┘         └───
pid      └───┘└┘                                          └──┘    └┘         └───
st   ─────────────────────────────────────────────────────────────────────────────────────
213        closure_mono this,
id         └──────────┘ └──┘
src  ─────┘└──────────┘
typ  ─────┘└──────────┘└──┘
doc  ─────┘            
txt  ─────┘            
par  ─────┘            
pid  ─────┘            
st   ──────────────────────┘└─
214      have : y ∈ closure K := this hy,
id                 └─────┘     └──┘ └┘
src      └─────┘  └─────┘ └──┘    
typ      └─────┘ └─────┘└──┘└──┘└┘
doc      └─────┘  └─────┘ └──┘    
txt      └─────┘          └──┘    
par      └─────┘          └──┘    
pid      └───┘└┘          └──┘    
st   ──────────────────────────────────┘└─
215      rwa closure_eq_of_is_closed (is_closed_eq f'.continuous f₁'.continuous) at this },
id           └─────────────────────┘  └──────────┘ └───────────┘ └────────────┘
src      └──┘└─────────────────────┘ └──────────┘└───────────┘└────────────┘└────────┘
typ      └──┘└─────────────────────┘ └──────────┘└───────────┘└────────────┘└────────┘
doc      └──┘                                                               └────────┘
txt      └──┘                                                               └────────┘
par      └──┘                                                               └────────┘
pid                                                                        └──────┘
st   ───────────────────────────────────────────────────────────────────────────────────┘└┘
216    rw H.1 at C,
id        
src    └─┘ └─────┘
typ    └─┘└─────┘
doc    └─┘ └─────┘
txt    └─┘ └─────┘
par    └─┘ └─────┘
pid       └─────┘
st   ────────────┘└─
217    ext y,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
pid       └┘
st   ──────┘└─
218    exact C y (mem_univ _)
id              └──────┘
src    └────┘   └──────┘└──┘
typ    └────┘ └──────┘└──┘
doc    └────┘           └──┘
txt    └────┘           └──┘
par    └────┘           └──┘
pid                    └─┘
st   ────────────────────────┘
219  end
st   └─┘
220  
221  theorem unique_diff_on.eq (H : unique_diff_on 𝕜 s) (hx : x ∈ s)
id                                  └────────────┘            
src                                 └────────────┘              
typ                                 └────────────┘            
doc                                 └────────────┘
222    (h : has_fderiv_within_at f f' s x) (h₁ : has_fderiv_within_at f f₁' s x) : f' = f₁' :=
id          └──────────────────┘  └┘          └──────────────────┘  └─┘      └┘  └─┘
src         └──────────────────┘                 └──────────────────┘                 
typ         └──────────────────┘  └┘          └──────────────────┘  └─┘      └┘  └─┘
doc         └──────────────────┘                 └──────────────────┘
223  unique_diff_within_at.eq (H x hx) h h₁
id   └──────────────────────┘    └┘   └┘
src  └──────────────────────┘
typ  └──────────────────────┘    └┘   └┘
doc  └──────────────────────┘
224  
225  end derivative_uniqueness
226  
227  section fderiv_properties
228  /-! ### Basic properties of the derivative -/
229  
230  theorem has_fderiv_at_filter_iff_tendsto :
231    has_fderiv_at_filter f f' x L ↔
id     └──────────────────┘  └┘   
src    └──────────────────┘          
typ    └──────────────────┘  └┘   
doc    └──────────────────┘
232    tendsto (λ x', ∥x' - x∥⁻¹ * ∥f x' - f x - f' (x' - x)∥) L (𝓝 0) :=
id     └─────┘    └┘  └┘  └┘   └┘     └┘  └┘       
src    └─────┘             └┘                            
typ    └─────┘    └┘  └┘  └┘   └┘     └┘  └┘       
doc    └─────┘                                                    
233  have h : ∀ x', ∥x' - x∥ = 0 → ∥f x' - f x - f' (x' - x)∥ = 0, from λ x' hx',
id              └┘  └┘         └┘     └┘  └┘               └┘ └─┘
src                                                  
typ             └┘  └┘         └┘     └┘  └┘               └┘ └─┘
234    by { rw [sub_eq_zero.1 ((norm_eq_zero (x' - x)).1 hx')], simp },
id              └─────────┘     └──────────┘  └┘       └─┘
src         └──┘└─────────┘└─┘  └──────────┘    └───┘   └┘  └───┘
typ         └──┘└─────────┘└─┘  └──────────┘ └┘└───┘└─┘└┘  └───┘
doc         └──┘           └─┘                   └───┘   └┘  └───┘
txt         └──┘           └─┘                   └───┘   └┘  └───┘
par         └──┘           └─┘                   └───┘   └┘  └───┘
pid           └┘           └─┘                   └───┘   └┘      
st       └──────────────────────────────────────────────────┘└──────┘└┘
235  begin
st   └─────
236    unfold has_fderiv_at_filter,
src    └─────────────────────────┘
typ    └─────────────────────────┘
doc    └─────────────────────────┘
txt    └─────────────────────────┘
par    └─────────────────────────┘
pid          └───────────────────┘
st   ────────────────────────────┘└─
237    rw [←is_o_norm_left, ←is_o_norm_right, is_o_iff_tendsto h],
id          └────────────┘   └─────────────┘  └──────────────┘ 
src    └───┘└────────────┘└─┘└─────────────┘└┘└──────────────┘ 
typ    └───┘└────────────┘└─┘└─────────────┘└┘└──────────────┘
doc    └───┘              └─┘               └┘                 
txt    └───┘              └─┘               └┘                 
par    └───┘              └─┘               └┘                 
pid      └─┘              └─┘               └┘                 
st   ────────────────────┘└────────────────┘└──────────────────┘└──
238    exact tendsto_congr (λ _, div_eq_inv_mul),
id           └───────────┘       └────────────┘
src    └────┘└───────────┘  └──┘└────────────┘
typ    └────┘└───────────┘  └──┘└────────────┘
doc    └────┘               └──┘              
txt    └────┘               └──┘              
par    └────┘               └──┘              
pid                        └──┘              
st   ──────────────────────────────────────────┘└─
239  end
st   ──┘
240  
241  theorem has_fderiv_within_at_iff_tendsto : has_fderiv_within_at f f' s x ↔
id                                              └──────────────────┘  └┘   
src                                             └──────────────────┘          
typ                                             └──────────────────┘  └┘   
doc                                             └──────────────────┘
242    tendsto (λ x', ∥x' - x∥⁻¹ * ∥f x' - f x - f' (x' - x)∥) (nhds_within x s) (𝓝 0) :=
id     └─────┘    └┘  └┘  └┘   └┘     └┘  └┘      └─────────┘     
src    └─────┘             └┘                          └─────────┘       
typ    └─────┘    └┘  └┘  └┘   └┘     └┘  └┘      └─────────┘     
doc    └─────┘                                                  └─────────┘       
243  has_fderiv_at_filter_iff_tendsto
id   └──────────────────────────────┘
src  └──────────────────────────────┘
typ  └──────────────────────────────┘
244  
245  theorem has_fderiv_at_iff_tendsto : has_fderiv_at f f' x ↔
id                                       └───────────┘  └┘  
src                                      └───────────┘        
typ                                      └───────────┘  └┘  
doc                                      └───────────┘
246    tendsto (λ x', ∥x' - x∥⁻¹ * ∥f x' - f x - f' (x' - x)∥) (𝓝 x) (𝓝 0) :=
id     └─────┘    └┘  └┘  └┘   └┘     └┘  └┘          
src    └─────┘             └┘                               
typ    └─────┘    └┘  └┘  └┘   └┘     └┘  └┘          
doc    └─────┘                                                       
247  has_fderiv_at_filter_iff_tendsto
id   └──────────────────────────────┘
src  └──────────────────────────────┘
typ  └──────────────────────────────┘
248  
249  theorem has_fderiv_at_iff_is_o_nhds_zero : has_fderiv_at f f' x ↔
id                                              └───────────┘  └┘  
src                                             └───────────┘        
typ                                             └───────────┘  └┘  
doc                                             └───────────┘
250    is_o (λh, f (x + h) - f x - f' h) (λh, h) (𝓝 0) :=
id     └──┘               └┘          
src    └──┘                                    
typ    └──┘               └┘          
doc    └──┘                                       
251  begin
st   └─────
252    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
253    { assume H,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
254      have : tendsto (λ (z : E), z + x) (𝓝 0) (𝓝 (0 + x)),
id              └─────┘                               
src      └─────┘└─────┘  └────┘ └─┘  └┘ └──┘   └┘  └┘
typ      └─────┘└─────┘  └────┘└─┘  └┘ └──┘   └┘ └┘
doc      └─────┘└─────┘  └────┘ └─┘   └┘ └──┘   └┘  └┘
txt      └─────┘         └────┘ └─┘   └┘  └──┘   └┘  └┘
par      └─────┘         └────┘ └─┘   └┘  └──┘   └┘  └┘
pid      └───┘└┘         └────┘ └─┘   └┘  └──┘   └┘  └┘
st   ──────────────────────────────────────────────────────┘└─
255        from tendsto_id.add tendsto_const_nhds,
id              └────────────┘ └────────────────┘
src        └───┘└────────────┘└────────────────┘
typ        └───┘└────────────┘└────────────────┘
doc        └───┘              
txt        └───┘              
par        └───┘              
pid        └───┘              
st   ───────────────────────────────────────────┘└─
256      rw [zero_add] at this,
id           └──────┘
src      └──┘└──────┘└───────┘
typ      └──┘└──────┘└───────┘
doc      └──┘        └───────┘
txt      └──┘        └───────┘
par      └──┘        └───────┘
pid        └┘        └──────┘
st   ───────────────┘└──────┘└─
257      refine (H.comp_tendsto this).congr _ _;
id               └────────────┘ └──┘
src      └─────┘ └────────────┘    └─────────┘
typ      └─────┘ └────────────┘└──┘└─────────┘
doc      └─────┘                   └─────────┘
txt      └─────┘                   └─────────┘
par      └─────┘                   └─────────┘
pid                               └─────────┘
st   ────────────────────────────────────────────
258        intro z; simp only [function.comp, add_sub_cancel', add_comm z] },
id                             └───────────┘  └─────────────┘  └──────┘ 
src        └─────┘  └─────────┘└───────────┘└┘└─────────────┘└┘└──────┘ └┘
typ        └─────┘  └─────────┘└───────────┘└┘└─────────────┘└┘└──────┘└┘
doc        └─────┘  └─────────┘             └┘               └┘         └┘
txt        └─────┘  └─────────┘             └┘               └┘         └┘
par        └─────┘  └─────────┘             └┘               └┘         └┘
pid             └┘      └──┘└┘             └┘               └┘         
st   ─────────────────────────────────────────────────────────────────────┘└┘
259    { assume H,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───────────┘└─
260      have : tendsto (λ (z : E), z - x) (𝓝 x) (𝓝 (x - x)),
id              └─────┘                                
src      └─────┘└─────┘  └────┘ └─┘  └┘   └┘      └┘
typ      └─────┘└─────┘  └────┘└─┘  └┘   └┘     └┘
doc      └─────┘└─────┘  └────┘ └─┘   └┘   └┘      └┘
txt      └─────┘         └────┘ └─┘   └┘   └┘      └┘
par      └─────┘         └────┘ └─┘   └┘   └┘      └┘
pid      └───┘└┘         └────┘ └─┘   └┘   └┘      └┘
st   ──────────────────────────────────────────────────────┘└─
261        from tendsto_id.sub tendsto_const_nhds,
id              └────────────┘ └────────────────┘
src        └───┘└────────────┘└────────────────┘
typ        └───┘└────────────┘└────────────────┘
doc        └───┘              
txt        └───┘              
par        └───┘              
pid        └───┘              
st   ───────────────────────────────────────────┘└─
262      rw [sub_self] at this,
id           └──────┘
src      └──┘└──────┘└───────┘
typ      └──┘└──────┘└───────┘
doc      └──┘        └───────┘
txt      └──┘        └───────┘
par      └──┘        └───────┘
pid        └┘        └──────┘
st   ───────────────┘└──────┘└─
263      refine (H.comp_tendsto this).congr _ _;
id               └────────────┘ └──┘
src      └─────┘ └────────────┘    └─────────┘
typ      └─────┘ └────────────┘└──┘└─────────┘
doc      └─────┘                   └─────────┘
txt      └─────┘                   └─────────┘
par      └─────┘                   └─────────┘
pid                               └─────────┘
st   ────────────────────────────────────────────
264        intro z; simp only [function.comp, add_sub_cancel'_right] }
id                             └───────────┘  └───────────────────┘
src        └─────┘  └─────────┘└───────────┘└┘└───────────────────┘└┘
typ        └─────┘  └─────────┘└───────────┘└┘└───────────────────┘└┘
doc        └─────┘  └─────────┘             └┘                     └┘
txt        └─────┘  └─────────┘             └┘                     └┘
par        └─────┘  └─────────┘             └┘                     └┘
pid             └┘      └──┘└┘             └┘                     
st   ───────────────────────────────────────────────────────────────┘└─
265  end
st   ──┘
266  
267  theorem has_fderiv_at_filter.mono (h : has_fderiv_at_filter f f' x L₂) (hst : L₁ ≤ L₂) :
id                                          └──────────────────┘  └┘  └┘         └┘  └┘
src                                         └──────────────────┘                      
typ                                         └──────────────────┘  └┘  └┘         └┘  └┘
doc                                         └──────────────────┘
268    has_fderiv_at_filter f f' x L₁ :=
id     └──────────────────┘  └┘  └┘
src    └──────────────────┘
typ    └──────────────────┘  └┘  └┘
doc    └──────────────────┘
269  h.mono hst
id   └───┘ └─┘
src   └───┘
typ  └───┘ └─┘
270  
271  theorem has_fderiv_within_at.mono (h : has_fderiv_within_at f f' t x) (hst : s ⊆ t) :
id                                          └──────────────────┘  └┘             
src                                         └──────────────────┘                    
typ                                         └──────────────────┘  └┘             
doc                                         └──────────────────┘
272    has_fderiv_within_at f f' s x :=
id     └──────────────────┘  └┘  
src    └──────────────────┘
typ    └──────────────────┘  └┘  
doc    └──────────────────┘
273  h.mono (nhds_within_mono _ hst)
id   └───┘  └──────────────┘   └─┘
src   └───┘  └──────────────┘
typ  └───┘  └──────────────┘   └─┘
274  
275  theorem has_fderiv_at.has_fderiv_at_filter (h : has_fderiv_at f f' x) (hL : L ≤ 𝓝 x) :
id                                                   └───────────┘  └┘            
src                                                  └───────────┘                  
typ                                                  └───────────┘  └┘            
doc                                                  └───────────┘                   
276    has_fderiv_at_filter f f' x L :=
id     └──────────────────┘  └┘  
src    └──────────────────┘
typ    └──────────────────┘  └┘  
doc    └──────────────────┘
277  h.mono hL
id   └───┘ └┘
src   └───┘
typ  └───┘ └┘
278  
279  theorem has_fderiv_at.has_fderiv_within_at
280    (h : has_fderiv_at f f' x) : has_fderiv_within_at f f' s x :=
id          └───────────┘  └┘     └──────────────────┘  └┘  
src         └───────────┘           └──────────────────┘
typ         └───────────┘  └┘     └──────────────────┘  └┘  
doc         └───────────┘           └──────────────────┘
281  h.has_fderiv_at_filter lattice.inf_le_left
id   └───────────────────┘ └─────────────────┘
src   └───────────────────┘ └─────────────────┘
typ  └───────────────────┘ └─────────────────┘
282  
283  lemma has_fderiv_within_at.differentiable_within_at (h : has_fderiv_within_at f f' s x) :
id                                                            └──────────────────┘  └┘  
src                                                           └──────────────────┘
typ                                                           └──────────────────┘  └┘  
doc                                                           └──────────────────┘
284    differentiable_within_at 𝕜 f s x :=
id     └──────────────────────┘    
src    └──────────────────────┘
typ    └──────────────────────┘    
doc    └──────────────────────┘
285  ⟨f', h⟩
id    └┘  
typ   └┘  
286  
287  lemma has_fderiv_at.differentiable_at (h : has_fderiv_at f f' x) : differentiable_at 𝕜 f x :=
id                                              └───────────┘  └┘     └───────────────┘   
src                                             └───────────┘           └───────────────┘
typ                                             └───────────┘  └┘     └───────────────┘   
doc                                             └───────────┘           └───────────────┘
288  ⟨f', h⟩
id    └┘  
typ   └┘  
289  
290  @[simp] lemma has_fderiv_within_at_univ :
doc    └──┘
291    has_fderiv_within_at f f' univ x ↔ has_fderiv_at f f' x :=
id     └──────────────────┘  └┘ └──┘   └───────────┘  └┘ 
src    └──────────────────┘      └──┘    └───────────┘
typ    └──────────────────┘  └┘ └──┘   └───────────┘  └┘ 
doc    └──────────────────┘               └───────────┘
292  by { simp only [has_fderiv_within_at, nhds_within_univ], refl }
id                   └──────────────────┘  └──────────────┘
src       └─────────┘└──────────────────┘└┘└──────────────┘  └───┘
typ       └─────────┘└──────────────────┘└┘└──────────────┘  └───┘
doc       └─────────┘└──────────────────┘└┘                  └───┘
txt       └─────────┘                    └┘                  └───┘
par       └─────────┘                    └┘                  └───┘
pid           └──┘└┘                    └┘                      
st     └───────────────────────────────────────────────────┘└─────┘└┘
293  
294  /-- Directional derivative agrees with `has_fderiv`. -/
295  lemma has_fderiv_at.lim (hf : has_fderiv_at f f' x) (v : E) {α : Type*} {c : α → 𝕜}
id                                 └───────────┘  └┘                              
src                                └───────────┘
typ                                └───────────┘  └┘                              
doc                                └───────────┘
296    {l : filter α} (hc : tendsto (λ n, ∥c n∥) l at_top) :
id          └────┘         └─────┘          └────┘
src         └────┘          └─────┘              └────┘
typ         └────┘         └─────┘          └────┘
doc                         └─────┘                └────┘
297    tendsto (λ n, (c n) • (f (x + (c n)⁻¹ • v) - f x)) l (𝓝 (f' v)) :=
id     └─────┘                   └┘             └┘ 
src    └─────┘                          └┘               
typ    └─────┘                   └┘             └┘ 
doc    └─────┘                                               
298  begin
st   └─────
299    refine (has_fderiv_within_at_univ.2 hf).lim _ (univ_mem_sets' (λ _, trivial)) hc _,
id             └───────────────────────┘   └┘         └────────────┘       └─────┘   └┘
src    └─────┘ └───────────────────────┘└─┘  └──────┘ └────────────┘  └──┘└─────┘└─┘  └┘
typ    └─────┘ └───────────────────────┘└─┘└┘└──────┘ └────────────┘  └──┘└─────┘└─┘└┘└┘
doc    └─────┘                          └─┘  └──────┘                 └──┘       └─┘  └┘
txt    └─────┘                          └─┘  └──────┘                 └──┘       └─┘  └┘
par    └─────┘                          └─┘  └──────┘                 └──┘       └─┘  └┘
pid                                    └─┘  └──────┘                 └──┘       └─┘  └┘
st   ───────────────────────────────────────────────────────────────────────────────────┘└─
300    assume U hU,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid    └─────────┘
st   ────────────┘└─
301    apply mem_sets_of_superset (ne_mem_of_tendsto_norm_at_top hc (0:𝕜)) _,
id           └──────────────────┘  └───────────────────────────┘ └┘    
src    └────┘└──────────────────┘ └───────────────────────────┘   └┘ └──┘
typ    └────┘└──────────────────┘ └───────────────────────────┘└┘ └┘└──┘
doc    └────┘                     └───────────────────────────┘   └┘ └──┘
txt    └────┘                                                     └┘ └──┘
par    └────┘                                                     └┘ └──┘
pid                                                              └┘ └──┘
st   ──────────────────────────────────────────────────────────────────────┘└─
302    assume y hy,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid    └─────────┘
st   ────────────┘└─
303    rw [mem_preimage],
id         └──────────┘
src    └──┘└──────────┘
typ    └──┘└──────────┘
doc    └──┘            
txt    └──┘            
par    └──┘            
pid      └┘            
st   ─────────────────┘└──
304    convert mem_of_nhds hU,
id             └─────────┘ └┘
src    └──────┘└─────────┘
typ    └──────┘└─────────┘└┘
doc    └──────┘           
txt    └──────┘           
par    └──────┘           
pid                      
st   ───────────────────────┘└─
305    rw [← mul_smul, mul_inv_cancel hy, one_smul]
id           └──────┘  └────────────┘ └┘  └──────┘
src    └────┘└──────┘└┘└────────────┘  └┘└──────┘└┘
typ    └────┘└──────┘└┘└────────────┘└┘└┘└──────┘└┘
doc    └────┘        └┘                └┘        └┘
txt    └────┘        └┘                └┘        └┘
par    └────┘        └┘                └┘        └┘
pid      └──┘        └┘                └┘        
st   ───────────────┘└─────────────────┘└────────┘
306  end
st   └─┘
307  
308  theorem has_fderiv_at_unique
309    (h₀ : has_fderiv_at f f₀' x) (h₁ : has_fderiv_at f f₁' x) : f₀' = f₁' :=
id           └───────────┘  └─┘         └───────────┘  └─┘     └─┘  └─┘
src          └───────────┘                └───────────┘                
typ          └───────────┘  └─┘         └───────────┘  └─┘     └─┘  └─┘
doc          └───────────┘                └───────────┘
310  begin
st   └─────
311    rw ← has_fderiv_within_at_univ at h₀ h₁,
id          └───────────────────────┘
src    └───┘└───────────────────────┘└───────┘
typ    └───┘└───────────────────────┘└───────┘
doc    └───┘                         └───────┘
txt    └───┘                         └───────┘
par    └───┘                         └───────┘
pid      └─┘                         └───────┘
st   ────────────────────────────────────────┘└─
312    exact unique_diff_within_at_univ.eq h₀ h₁
id           └───────────────────────────┘ └┘ └┘
src    └────┘└───────────────────────────┘    
typ    └────┘└───────────────────────────┘└┘└┘
doc    └────┘└───────────────────────────┘    
txt    └────┘                                 
par    └────┘                                 
pid                                          
st   ───────────────────────────────────────────┘
313  end
st   └─┘
314  
315  lemma has_fderiv_within_at_inter' (h : t ∈ nhds_within x s) :
id                                            └─────────┘  
src                                            └─────────┘
typ                                           └─────────┘  
doc                                             └─────────┘
316    has_fderiv_within_at f f' (s ∩ t) x ↔ has_fderiv_within_at f f' s x :=
id     └──────────────────┘  └┘        └──────────────────┘  └┘  
src    └──────────────────┘                └──────────────────┘
typ    └──────────────────┘  └┘        └──────────────────┘  └┘  
doc    └──────────────────┘                  └──────────────────┘
317  by simp [has_fderiv_within_at, nhds_within_restrict'' s h]
id            └──────────────────┘  └────────────────────┘  
src     └────┘└──────────────────┘└┘└────────────────────┘  └─
typ     └────┘└──────────────────┘└┘└────────────────────┘└─
doc     └────┘└──────────────────┘└┘                        └─
txt     └────┘                    └┘                        └─
par     └────┘                    └┘                        └─
pid                             └┘                        
st     └────────────────────────────────────────────────────────
318  
src  
typ  
doc  
txt  
par  
pid  
st   
319  lemma has_fderiv_within_at_inter (h : t ∈ 𝓝 x) :
id                                            
src                                           
typ                                           
doc                                            
320    has_fderiv_within_at f f' (s ∩ t) x ↔ has_fderiv_within_at f f' s x :=
id     └──────────────────┘  └┘        └──────────────────┘  └┘  
src    └──────────────────┘                └──────────────────┘
typ    └──────────────────┘  └┘        └──────────────────┘  └┘  
doc    └──────────────────┘                  └──────────────────┘
321  by simp [has_fderiv_within_at, nhds_within_restrict' s h]
id            └──────────────────┘  └───────────────────┘  
src     └────┘└──────────────────┘└┘└───────────────────┘  └─
typ     └────┘└──────────────────┘└┘└───────────────────┘└─
doc     └────┘└──────────────────┘└┘                       └─
txt     └────┘                    └┘                       └─
par     └────┘                    └┘                       └─
pid                             └┘                       
st     └───────────────────────────────────────────────────────
322  
src  
typ  
doc  
txt  
par  
pid  
st   
323  lemma has_fderiv_within_at.union (hs : has_fderiv_within_at f f' s x) (ht : has_fderiv_within_at f f' t x) :
id                                          └──────────────────┘  └┘          └──────────────────┘  └┘  
src                                         └──────────────────┘                 └──────────────────┘
typ                                         └──────────────────┘  └┘          └──────────────────┘  └┘  
doc                                         └──────────────────┘                 └──────────────────┘
324    has_fderiv_within_at f f' (s ∪ t) x :=
id     └──────────────────┘  └┘      
src    └──────────────────┘         
typ    └──────────────────┘  └┘      
doc    └──────────────────┘
325  begin
st   └─────
326    simp only [has_fderiv_within_at, nhds_within_union],
id                └──────────────────┘  └───────────────┘
src    └─────────┘└──────────────────┘└┘└───────────────┘
typ    └─────────┘└──────────────────┘└┘└───────────────┘
doc    └─────────┘└──────────────────┘└┘                 
txt    └─────────┘                    └┘                 
par    └─────────┘                    └┘                 
pid        └──┘└┘                    └┘                 
st   ────────────────────────────────────────────────────┘└─
327    exact hs.join ht,
id           └─────┘ └┘
src    └────┘└─────┘
typ    └────┘└─────┘└┘
doc    └────┘       
txt    └────┘       
par    └────┘       
pid                
st   ─────────────────┘└─
328  end
st   ──┘
329  
330  lemma has_fderiv_within_at.nhds_within (h : has_fderiv_within_at f f' s x)
id                                               └──────────────────┘  └┘  
src                                              └──────────────────┘
typ                                              └──────────────────┘  └┘  
doc                                              └──────────────────┘
331    (ht : s ∈ nhds_within x t) : has_fderiv_within_at f f' t x :=
id             └─────────┘      └──────────────────┘  └┘  
src             └─────────┘        └──────────────────┘
typ            └─────────┘      └──────────────────┘  └┘  
doc              └─────────┘        └──────────────────┘
332  (has_fderiv_within_at_inter' ht).1 (h.mono (inter_subset_right _ _))
id    └─────────────────────────┘ └┘    └───┘  └────────────────┘
src   └─────────────────────────┘        └───┘  └────────────────┘
typ   └─────────────────────────┘ └┘    └───┘  └────────────────┘
333  
334  lemma has_fderiv_within_at.has_fderiv_at (h : has_fderiv_within_at f f' s x) (hs : s ∈ 𝓝 x) :
id                                                 └──────────────────┘  └┘             
src                                                └──────────────────┘                    
typ                                                └──────────────────┘  └┘             
doc                                                └──────────────────┘                     
335    has_fderiv_at f f' x :=
id     └───────────┘  └┘ 
src    └───────────┘
typ    └───────────┘  └┘ 
doc    └───────────┘
336  by rwa [← univ_inter s, has_fderiv_within_at_inter hs, has_fderiv_within_at_univ] at h
id             └────────┘   └────────────────────────┘ └┘  └───────────────────────┘
src     └─────┘└────────┘ └┘└────────────────────────┘  └┘└───────────────────────┘└──────
typ     └─────┘└────────┘└┘└────────────────────────┘└┘└┘└───────────────────────┘└──────
doc     └─────┘           └┘                            └┘                         └──────
txt     └─────┘           └┘                            └┘                         └──────
par     └─────┘           └┘                            └┘                         └──────
pid        └──┘           └┘                            └┘                         └───┘
st     └──────────────────┘└─────────────────────────────┘└─────────────────────────┘└─────
337  
src  
typ  
doc  
txt  
par  
pid  
st   
338  lemma differentiable_within_at.has_fderiv_within_at (h : differentiable_within_at 𝕜 f s x) :
id                                                            └──────────────────────┘    
src                                                           └──────────────────────┘
typ                                                           └──────────────────────┘    
doc                                                           └──────────────────────┘
339    has_fderiv_within_at f (fderiv_within 𝕜 f s x) s x :=
id     └──────────────────┘   └───────────┘       
src    └──────────────────┘    └───────────┘
typ    └──────────────────┘   └───────────┘       
doc    └──────────────────┘    └───────────┘
340  begin
st   └─────
341    dunfold fderiv_within,
src    └───────────────────┘
typ    └───────────────────┘
doc    └───────────────────┘
txt    └───────────────────┘
par    └───────────────────┘
pid           └────────────┘
st   ──────────────────────┘└─
342    dunfold differentiable_within_at at h,
src    └───────────────────────────────────┘
typ    └───────────────────────────────────┘
doc    └───────────────────────────────────┘
txt    └───────────────────────────────────┘
par    └───────────────────────────────────┘
pid           └───────────────────────┘└───┘
st   ──────────────────────────────────────┘└─
343    rw dif_pos h,
id        └─────┘ 
src    └─┘└─────┘
typ    └─┘└─────┘
doc    └─┘       
txt    └─┘       
par    └─┘       
pid             
st   ─────────────┘└─
344    exact classical.some_spec h
id           └─────────────────┘ 
src    └────┘└─────────────────┘ 
typ    └────┘└─────────────────┘
doc    └────┘                    
txt    └────┘                    
par    └────┘                    
pid                             
st   ─────────────────────────────┘
345  end
st   └─┘
346  
347  lemma differentiable_at.has_fderiv_at (h : differentiable_at 𝕜 f x) :
id                                              └───────────────┘   
src                                             └───────────────┘
typ                                             └───────────────┘   
doc                                             └───────────────┘
348    has_fderiv_at f (fderiv 𝕜 f x) x :=
id     └───────────┘   └────┘     
src    └───────────┘    └────┘
typ    └───────────┘   └────┘     
doc    └───────────┘    └────┘
349  begin
st   └─────
350    dunfold fderiv,
src    └────────────┘
typ    └────────────┘
doc    └────────────┘
txt    └────────────┘
par    └────────────┘
pid           └─────┘
st   ───────────────┘└─
351    dunfold differentiable_at at h,
src    └────────────────────────────┘
typ    └────────────────────────────┘
doc    └────────────────────────────┘
txt    └────────────────────────────┘
par    └────────────────────────────┘
pid           └────────────────┘└───┘
st   ───────────────────────────────┘└─
352    rw dif_pos h,
id        └─────┘ 
src    └─┘└─────┘
typ    └─┘└─────┘
doc    └─┘       
txt    └─┘       
par    └─┘       
pid             
st   ─────────────┘└─
353    exact classical.some_spec h
id           └─────────────────┘ 
src    └────┘└─────────────────┘ 
typ    └────┘└─────────────────┘
doc    └────┘                    
txt    └────┘                    
par    └────┘                    
pid                             
st   ─────────────────────────────┘
354  end
st   └─┘
355  
356  lemma has_fderiv_at.fderiv (h : has_fderiv_at f f' x) : fderiv 𝕜 f x = f' :=
id                                   └───────────┘  └┘     └────┘     └┘
src                                  └───────────┘           └────┘       
typ                                  └───────────┘  └┘     └────┘     └┘
doc                                  └───────────┘           └────┘
357  by { ext, rw has_fderiv_at_unique h h.differentiable_at.has_fderiv_at }
id                └──────────────────┘   └───────────────────────────────┘
src       └─┘  └─┘└──────────────────┘ └───────────────────────────────┘
typ       └─┘  └─┘└──────────────────┘ └───────────────────────────────┘
doc       └─┘  └─┘                                                      
txt       └─┘  └─┘                                                      
par       └─┘  └─┘                                                      
pid                                                                    
st     └────┘└────────────────────────────────────────────────────────────┘└┘
358  
359  lemma has_fderiv_within_at.fderiv_within
360    (h : has_fderiv_within_at f f' s x) (hxs : unique_diff_within_at 𝕜 s x) :
id          └──────────────────┘  └┘           └───────────────────┘   
src         └──────────────────┘                  └───────────────────┘
typ         └──────────────────┘  └┘           └───────────────────┘   
doc         └──────────────────┘                  └───────────────────┘
361    fderiv_within 𝕜 f s x = f' :=
id     └───────────┘      └┘
src    └───────────┘         
typ    └───────────┘      └┘
doc    └───────────┘
362  by { ext, rw hxs.eq h h.differentiable_within_at.has_fderiv_within_at }
id                └────┘   └─────────────────────────────────────────────┘
src       └─┘  └─┘└────┘ └─────────────────────────────────────────────┘
typ       └─┘  └─┘└────┘ └─────────────────────────────────────────────┘
doc       └─┘  └─┘└────┘                                                
txt       └─┘  └─┘                                                      
par       └─┘  └─┘                                                      
pid                                                                    
st     └────┘└────────────────────────────────────────────────────────────┘└┘
363  
364  /-- If `x` is not in the closure of `s`, then `f` has any derivative at `x` within `s`,
365  as this statement is empty. -/
366  lemma has_fderiv_within_at_of_not_mem_closure (h : x ∉ closure s) :
id                                                        └─────┘ 
src                                                        └─────┘
typ                                                       └─────┘ 
doc                                                         └─────┘
367    has_fderiv_within_at f f' s x :=
id     └──────────────────┘  └┘  
src    └──────────────────┘
typ    └──────────────────┘  └┘  
doc    └──────────────────┘
368  begin
st   └─────
369    simp [mem_closure_iff_nhds_within_ne_bot] at h,
id           └────────────────────────────────┘
src    └────┘└────────────────────────────────┘└────┘
typ    └────┘└────────────────────────────────┘└────┘
doc    └────┘                                  └────┘
txt    └────┘                                  └────┘
par    └────┘                                  └────┘
pid                                          └──┘
st   ───────────────────────────────────────────────┘└─
370    simp [has_fderiv_within_at, has_fderiv_at_filter, h, is_o, is_O_with],
id           └──────────────────┘  └──────────────────┘    └──┘  └───────┘
src    └────┘└──────────────────┘└┘└──────────────────┘└┘ └┘└──┘└┘└───────┘
typ    └────┘└──────────────────┘└┘└──────────────────┘└┘└┘└──┘└┘└───────┘
doc    └────┘└──────────────────┘└┘└──────────────────┘└┘ └┘└──┘└┘└───────┘
txt    └────┘                    └┘                    └┘ └┘    └┘         
par    └────┘                    └┘                    └┘ └┘    └┘         
pid                            └┘                    └┘ └┘    └┘         
st   ──────────────────────────────────────────────────────────────────────┘└─
371  end
st   ──┘
372  
373  lemma differentiable_within_at.mono (h : differentiable_within_at 𝕜 f t x) (st : s ⊆ t) :
id                                            └──────────────────────┘              
src                                           └──────────────────────┘                  
typ                                           └──────────────────────┘              
doc                                           └──────────────────────┘
374    differentiable_within_at 𝕜 f s x :=
id     └──────────────────────┘    
src    └──────────────────────┘
typ    └──────────────────────┘    
doc    └──────────────────────┘
375  begin
st   └─────
376    rcases h with ⟨f', hf'⟩,
id            
src    └─────┘ └─────────────┘
typ    └─────┘└─────────────┘
doc    └─────┘ └─────────────┘
txt    └─────┘ └─────────────┘
par    └─────┘ └─────────────┘
pid           └─────────────┘
st   ────────────────────────┘└─
377    exact ⟨f', hf'.mono st⟩
id            └┘  └──────┘ └┘
src    └────┘   └┘└──────┘  └┘
typ    └────┘ └┘└┘└──────┘└┘└┘
doc    └────┘   └┘          └┘
txt    └────┘   └┘          └┘
par    └────┘   └┘          └┘
pid            └┘          
st   ─────────────────────────┘
378  end
st   └─┘
379  
380  lemma differentiable_within_at_univ :
381    differentiable_within_at 𝕜 f univ x ↔ differentiable_at 𝕜 f x :=
id     └──────────────────────┘   └──┘   └───────────────┘   
src    └──────────────────────┘     └──┘    └───────────────┘
typ    └──────────────────────┘   └──┘   └───────────────┘   
doc    └──────────────────────┘              └───────────────┘
382  by simp only [differentiable_within_at, has_fderiv_within_at_univ, differentiable_at]
id                 └──────────────────────┘  └───────────────────────┘  └───────────────┘
src     └─────────┘└──────────────────────┘└┘└───────────────────────┘└┘└───────────────┘└─
typ     └─────────┘└──────────────────────┘└┘└───────────────────────┘└┘└───────────────┘└─
doc     └─────────┘└──────────────────────┘└┘                         └┘└───────────────┘└─
txt     └─────────┘                        └┘                         └┘                 └─
par     └─────────┘                        └┘                         └┘                 └─
pid         └──┘└┘                        └┘                         └┘                 
st     └───────────────────────────────────────────────────────────────────────────────────
383  
src  
typ  
doc  
txt  
par  
pid  
st   
384  lemma differentiable_within_at_inter (ht : t ∈ 𝓝 x) :
id                                                 
src                                                
typ                                                
doc                                                 
385    differentiable_within_at 𝕜 f (s ∩ t) x ↔ differentiable_within_at 𝕜 f s x :=
id     └──────────────────────┘          └──────────────────────┘    
src    └──────────────────────┘               └──────────────────────┘
typ    └──────────────────────┘          └──────────────────────┘    
doc    └──────────────────────┘                 └──────────────────────┘
386  by simp only [differentiable_within_at, has_fderiv_within_at, has_fderiv_at_filter,
id                 └──────────────────────┘  └──────────────────┘  └──────────────────┘
src     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
typ     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
doc     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
txt     └─────────┘                        └┘                    └┘                    └─
par     └─────────┘                        └┘                    └┘                    └─
pid         └──┘└┘                        └┘                    └┘                    └─
st     └─────────────────────────────────────────────────────────────────────────────────
387      nhds_within_restrict' s ht]
id       └───────────────────┘  └┘
src  ───┘└───────────────────┘   └─
typ  ───┘└───────────────────┘└┘└─
doc  ───┘                        └─
txt  ───┘                        └─
par  ───┘                        └─
pid  ───┘                        
st   ────────────────────────────────
388  
src  
typ  
doc  
txt  
par  
pid  
st   
389  lemma differentiable_within_at_inter' (ht : t ∈ nhds_within x s) :
id                                                 └─────────┘  
src                                                 └─────────┘
typ                                                └─────────┘  
doc                                                  └─────────┘
390    differentiable_within_at 𝕜 f (s ∩ t) x ↔ differentiable_within_at 𝕜 f s x :=
id     └──────────────────────┘          └──────────────────────┘    
src    └──────────────────────┘               └──────────────────────┘
typ    └──────────────────────┘          └──────────────────────┘    
doc    └──────────────────────┘                 └──────────────────────┘
391  by simp only [differentiable_within_at, has_fderiv_within_at, has_fderiv_at_filter,
id                 └──────────────────────┘  └──────────────────┘  └──────────────────┘
src     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
typ     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
doc     └─────────┘└──────────────────────┘└┘└──────────────────┘└┘└──────────────────┘└─
txt     └─────────┘                        └┘                    └┘                    └─
par     └─────────┘                        └┘                    └┘                    └─
pid         └──┘└┘                        └┘                    └┘                    └─
st     └─────────────────────────────────────────────────────────────────────────────────
392      nhds_within_restrict'' s ht]
id       └────────────────────┘  └┘
src  ───┘└────────────────────┘   └─
typ  ───┘└────────────────────┘└┘└─
doc  ───┘                         └─
txt  ───┘                         └─
par  ───┘                         └─
pid  ───┘                         
st   ─────────────────────────────────
393  
src  
typ  
doc  
txt  
par  
pid  
st   
394  lemma differentiable_at.differentiable_within_at
395    (h : differentiable_at 𝕜 f x) : differentiable_within_at 𝕜 f s x :=
id          └───────────────┘       └──────────────────────┘    
src         └───────────────┘          └──────────────────────┘
typ         └───────────────┘       └──────────────────────┘    
doc         └───────────────┘          └──────────────────────┘
396  (differentiable_within_at_univ.2 h).mono (subset_univ _)
id    └───────────────────────────┘   └──┘   └─────────┘
src   └───────────────────────────┘    └──┘   └─────────┘
typ   └───────────────────────────┘   └──┘   └─────────┘
397  
398  lemma differentiable_within_at.differentiable_at
399    (h : differentiable_within_at 𝕜 f s x) (hs : s ∈ 𝓝 x) : differentiable_at 𝕜 f x :=
id          └──────────────────────┘                   └───────────────┘   
src         └──────────────────────┘                         └───────────────┘
typ         └──────────────────────┘                   └───────────────┘   
doc         └──────────────────────┘                          └───────────────┘
400  h.imp (λ f' hf', hf'.has_fderiv_at hs)
id   └──┘    └┘ └─┘  └─┘└────────────┘ └┘
src   └──┘               └────────────┘
typ  └──┘    └┘ └─┘  └─┘└────────────┘ └┘
401  
402  lemma differentiable_at.fderiv_within
403    (h : differentiable_at 𝕜 f x) (hxs : unique_diff_within_at 𝕜 s x) :
id          └───────────────┘            └───────────────────┘   
src         └───────────────┘               └───────────────────┘
typ         └───────────────┘            └───────────────────┘   
doc         └───────────────┘               └───────────────────┘
404    fderiv_within 𝕜 f s x = fderiv 𝕜 f x :=
id     └───────────┘      └────┘   
src    └───────────┘          └────┘
typ    └───────────┘      └────┘   
doc    └───────────┘           └────┘
405  begin
st   └─────
406    apply has_fderiv_within_at.fderiv_within _ hxs,
id           └────────────────────────────────┘   └─┘
src    └────┘└────────────────────────────────┘└─┘
typ    └────┘└────────────────────────────────┘└─┘└─┘
doc    └────┘                                  └─┘
txt    └────┘                                  └─┘
par    └────┘                                  └─┘
pid                                           └─┘
st   ───────────────────────────────────────────────┘└─
407    exact h.has_fderiv_at.has_fderiv_within_at
id           └──────────────────────────────────┘
src    └────┘└──────────────────────────────────┘
typ    └────┘└──────────────────────────────────┘
doc    └────┘                                    
txt    └────┘                                    
par    └────┘                                    
pid                                             
st   ────────────────────────────────────────────┘
408  end
st   └─┘
409  
410  lemma differentiable_on.mono (h : differentiable_on 𝕜 f t) (st : s ⊆ t) :
id                                     └───────────────┘             
src                                    └───────────────┘                
typ                                    └───────────────┘             
doc                                    └───────────────┘
411    differentiable_on 𝕜 f s :=
id     └───────────────┘   
src    └───────────────┘
typ    └───────────────┘   
doc    └───────────────┘
412  λx hx, (h x (st hx)).mono st
id     └┘      └┘ └┘  └──┘  └┘
src                      └──┘
typ    └┘      └┘ └┘  └──┘  └┘
413  
414  lemma differentiable_on_univ :
415    differentiable_on 𝕜 f univ ↔ differentiable 𝕜 f :=
id     └───────────────┘   └──┘  └────────────┘  
src    └───────────────┘     └──┘  └────────────┘
typ    └───────────────┘   └──┘  └────────────┘  
doc    └───────────────┘            └────────────┘
416  by { simp [differentiable_on, differentiable_within_at_univ], refl }
id              └───────────────┘  └───────────────────────────┘
src       └────┘└───────────────┘└┘└───────────────────────────┘  └───┘
typ       └────┘└───────────────┘└┘└───────────────────────────┘  └───┘
doc       └────┘└───────────────┘└┘                               └───┘
txt       └────┘                 └┘                               └───┘
par       └────┘                 └┘                               └───┘
pid                            └┘                                   
st     └────────────────────────────────────────────────────────┘└─────┘└┘
417  
418  lemma differentiable.differentiable_on (h : differentiable 𝕜 f) : differentiable_on 𝕜 f s :=
id                                               └────────────┘      └───────────────┘   
src                                              └────────────┘        └───────────────┘
typ                                              └────────────┘      └───────────────┘   
doc                                              └────────────┘        └───────────────┘
419  (differentiable_on_univ.2 h).mono (subset_univ _)
id    └────────────────────┘   └──┘   └─────────┘
src   └────────────────────┘    └──┘   └─────────┘
typ   └────────────────────┘   └──┘   └─────────┘
420  
421  lemma differentiable_on_of_locally_differentiable_on
422    (h : ∀x∈s, ∃u, is_open u ∧ x ∈ u ∧ differentiable_on 𝕜 f (s ∩ u)) : differentiable_on 𝕜 f s :=
id               └─────┘       └───────────────┘           └───────────────┘   
src                 └─────┘          └───────────────┘               └───────────────┘
typ              └─────┘       └───────────────┘           └───────────────┘   
doc                   └─────┘             └───────────────┘                └───────────────┘
423  begin
st   └─────
424    assume x xs,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid    └─────────┘
st   ────────────┘└─
425    rcases h x xs with ⟨t, t_open, xt, ht⟩,
id              └┘
src    └─────┘    └───────────────────────┘
typ    └─────┘└┘└───────────────────────┘
doc    └─────┘    └───────────────────────┘
txt    └─────┘    └───────────────────────┘
par    └─────┘    └───────────────────────┘
pid              └───────────────────────┘
st   ───────────────────────────────────────┘└─
426    exact (differentiable_within_at_inter (mem_nhds_sets t_open xt)).1 (ht x ⟨xs, xt⟩)
id            └────────────────────────────┘  └───────────┘ └────┘         └┘   └┘  └┘
src    └────┘ └────────────────────────────┘ └───────────┘        └───┘       └┘  └─┘
typ    └────┘ └────────────────────────────┘ └───────────┘└────┘  └───┘ └┘ └┘└┘└┘└─┘
doc    └────┘                                                     └───┘       └┘  └─┘
txt    └────┘                                                     └───┘       └┘  └─┘
par    └────┘                                                     └───┘       └┘  └─┘
pid                                                              └───┘       └┘  └┘
st   ────────────────────────────────────────────────────────────────────────────────────┘
427  end
st   └─┘
428  
429  lemma fderiv_within_subset (st : s ⊆ t) (ht : unique_diff_within_at 𝕜 s x)
id                                              └───────────────────┘   
src                                               └───────────────────┘
typ                                             └───────────────────┘   
doc                                                └───────────────────┘
430    (h : differentiable_within_at 𝕜 f t x) :
id          └──────────────────────┘    
src         └──────────────────────┘
typ         └──────────────────────┘    
doc         └──────────────────────┘
431    fderiv_within 𝕜 f s x = fderiv_within 𝕜 f t x :=
id     └───────────┘      └───────────┘    
src    └───────────┘          └───────────┘
typ    └───────────┘      └───────────┘    
doc    └───────────┘           └───────────┘
432  ((differentiable_within_at.has_fderiv_within_at h).mono st).fderiv_within ht
id     └───────────────────────────────────────────┘  └──┘  └┘ └───────────┘  └┘
src    └───────────────────────────────────────────┘   └──┘     └───────────┘
typ    └───────────────────────────────────────────┘  └──┘  └┘ └───────────┘  └┘
433  
434  @[simp] lemma fderiv_within_univ : fderiv_within 𝕜 f univ = fderiv 𝕜 f :=
id                                      └───────────┘   └──┘  └────┘  
src                                     └───────────┘     └──┘  └────┘
typ                                     └───────────┘   └──┘  └────┘  
doc    └──┘                             └───────────┘            └────┘
435  begin
st   └─────
436    ext x : 1,
src    └───────┘
typ    └───────┘
doc    └───────┘
txt    └───────┘
par    └───────┘
pid       └┘└─┘
st   ──────────┘└─
437    by_cases h : differentiable_at 𝕜 f x,
id                  └───────────────┘   
src    └───────┘ └─┘└───────────────┘  
typ    └───────┘ └─┘└───────────────┘
doc    └───────┘ └─┘└───────────────┘  
txt    └───────┘ └─┘                   
par    └───────┘ └─┘                   
pid             └─┘                   
st   ─────────────────────────────────────┘└─
438    { apply has_fderiv_within_at.fderiv_within _ (is_open_univ.unique_diff_within_at (mem_univ _)),
id             └────────────────────────────────┘    └────────────────────────────────┘  └──────┘
src      └────┘└────────────────────────────────┘└─┘ └────────────────────────────────┘ └──────┘└──┘
typ      └────┘└────────────────────────────────┘└─┘ └────────────────────────────────┘ └──────┘└──┘
doc      └────┘                                  └─┘                                            └──┘
txt      └────┘                                  └─┘                                            └──┘
par      └────┘                                  └─┘                                            └──┘
pid                                             └─┘                                            └──┘
st   ───┘└──────────────────────────────────────────────────────────────────────────────────────────┘└─
439      rw has_fderiv_within_at_univ,
id          └───────────────────────┘
src      └─┘└───────────────────────┘
typ      └─┘└───────────────────────┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ───────────────────────────────┘└─
440      apply h.has_fderiv_at },
src      └────┘               
typ      └────┘               
doc      └────┘               
txt      └────┘               
par      └────┘               
pid                          
st   ─────────────────────────┘└┘
441    { have : ¬ differentiable_within_at 𝕜 f univ x,
id                └──────────────────────┘   └──┘ 
src      └─────┘ └──────────────────────┘  └──┘
typ      └─────┘ └──────────────────────┘└──┘
doc      └─────┘ └──────────────────────┘      
txt      └─────┘                               
par      └─────┘                               
pid      └───┘└┘                               
st   ───────────────────────────────────────────────┘
442        by contrapose! h; rwa ← differentiable_within_at_univ,
id                                 └───────────────────────────┘
src           └───────────┘  └────┘└───────────────────────────┘
typ           └───────────┘  └────┘└───────────────────────────┘
doc           └───────────┘  └────┘
txt           └───────────┘  └────┘
par           └───────────┘  └────┘
pid                     └┘     └─┘
st                                                              └─
443      rw [fderiv_zero_of_not_differentiable_at h,
id           └──────────────────────────────────┘ 
src      └──┘└──────────────────────────────────┘ └─
typ      └──┘└──────────────────────────────────┘└─
doc      └──┘                                     └─
txt      └──┘                                     └─
par      └──┘                                     └─
pid        └┘                                     └─
st   ─────────────────────────────────────────────┘└─
444          fderiv_within_zero_of_not_differentiable_within_at this] }
id           └────────────────────────────────────────────────┘ └──┘
src  ───────┘└────────────────────────────────────────────────┘    └┘
typ  ───────┘└────────────────────────────────────────────────┘└──┘└┘
doc  ───────┘                                                      └┘
txt  ───────┘                                                      └┘
par  ───────┘                                                      └┘
pid  ───────┘                                                      
st   ──────────────────────────────────────────────────────────────┘└─
445  end
st   ──┘
446  
447  lemma fderiv_within_inter (ht : t ∈ 𝓝 x) (hs : unique_diff_within_at 𝕜 s x) :
id                                              └───────────────────┘   
src                                               └───────────────────┘
typ                                             └───────────────────┘   
doc                                                └───────────────────┘
448    fderiv_within 𝕜 f (s ∩ t) x = fderiv_within 𝕜 f s x :=
id     └───────────┘          └───────────┘    
src    └───────────┘               └───────────┘
typ    └───────────┘          └───────────┘    
doc    └───────────┘                 └───────────┘
449  begin
st   └─────
450    by_cases h : differentiable_within_at 𝕜 f (s ∩ t) x,
id                  └──────────────────────┘        
src    └───────┘ └─┘└──────────────────────┘     └┘
typ    └───────┘ └─┘└──────────────────────┘ └┘
doc    └───────┘ └─┘└──────────────────────┘      └┘
txt    └───────┘ └─┘                              └┘
par    └───────┘ └─┘                              └┘
pid             └─┘                              └┘
st   ────────────────────────────────────────────────────┘└─
451    { apply fderiv_within_subset (inter_subset_left _ _) _ ((differentiable_within_at_inter ht).1 h),
id             └──────────────────┘  └───────────────┘          └────────────────────────────┘ └┘    
src      └────┘└──────────────────┘ └───────────────┘└──────┘  └────────────────────────────┘  └──┘ 
typ      └────┘└──────────────────┘ └───────────────┘└──────┘  └────────────────────────────┘└┘└──┘
doc      └────┘                                      └──────┘                                  └──┘ 
txt      └────┘                                      └──────┘                                  └──┘ 
par      └────┘                                      └──────┘                                  └──┘ 
pid                                                 └──────┘                                  └──┘ 
st   ───┘└────────────────────────────────────────────────────────────────────────────────────────────┘└─
452      apply hs.inter ht },
id             └──────┘ └┘
src      └────┘└──────┘  
typ      └────┘└──────┘└┘
doc      └────┘          
txt      └────┘          
par      └────┘          
pid                     
st   ─────────────────────┘└┘
453    { have : ¬ differentiable_within_at 𝕜 f s x,
id                └──────────────────────┘    
src      └─────┘ └──────────────────────┘   
typ      └─────┘ └──────────────────────┘
doc      └─────┘ └──────────────────────┘   
txt      └─────┘                            
par      └─────┘                            
pid      └───┘└┘                            
st   ────────────────────────────────────────────┘
454        by contrapose! h; rw differentiable_within_at_inter; assumption,
id                              └────────────────────────────┘
src           └───────────┘  └─┘└────────────────────────────┘  └────────┘
typ           └───────────┘  └─┘└────────────────────────────┘  └────────┘
doc           └───────────┘  └─┘                                └────────┘
txt           └───────────┘  └─┘                                └────────┘
par           └───────────┘  └─┘                                └────────┘
pid                     └┘    
st                              └────────────────────────────┘            └─
455      rw [fderiv_within_zero_of_not_differentiable_within_at h,
id           └────────────────────────────────────────────────┘ 
src      └──┘└────────────────────────────────────────────────┘ └─
typ      └──┘└────────────────────────────────────────────────┘└─
doc      └──┘                                                   └─
txt      └──┘                                                   └─
par      └──┘                                                   └─
pid        └┘                                                   └─
st   ───────────────────────────────────────────────────────────┘└─
456          fderiv_within_zero_of_not_differentiable_within_at this] }
id           └────────────────────────────────────────────────┘ └──┘
src  ───────┘└────────────────────────────────────────────────┘    └┘
typ  ───────┘└────────────────────────────────────────────────┘└──┘└┘
doc  ───────┘                                                      └┘
txt  ───────┘                                                      └┘
par  ───────┘                                                      └┘
pid  ───────┘                                                      
st   ──────────────────────────────────────────────────────────────┘└─
457  end
st   ──┘
458  
459  end fderiv_properties
460  
461  section congr
462  /-! ### congr properties of the derivative -/
463  
464  theorem has_fderiv_at_filter_congr_of_mem_sets
465    (hx : f₀ x = f₁ x) (h₀ : ∀ᶠ x in L, f₀ x = f₁ x) (h₁ : ∀ x, f₀' x = f₁' x) :
id           └┘   └┘         └┘  └┘  └┘   └┘             └─┘   └─┘ 
src                            └┘   └┘                                
typ          └┘   └┘         └┘  └┘  └┘   └┘             └─┘   └─┘ 
doc                             └┘   └┘  
466    has_fderiv_at_filter f₀ f₀' x L ↔ has_fderiv_at_filter f₁ f₁' x L :=
id     └──────────────────┘ └┘ └─┘    └──────────────────┘ └┘ └─┘  
src    └──────────────────┘             └──────────────────┘
typ    └──────────────────┘ └┘ └─┘    └──────────────────┘ └┘ └─┘  
doc    └──────────────────┘              └──────────────────┘
467  by { rw (ext h₁), exact is_o_congr
id            └─┘ └┘         └────────┘
src       └─┘ └─┘    └────┘└────────┘
typ       └─┘ └─┘└┘  └────┘└────────┘
doc       └─┘        └────┘          
txt       └─┘        └────┘          
par       └─┘        └────┘          
pid                                
st     └────────────┘└──────────────────
468    (by filter_upwards [h₀] λ x (h : _ = _), by simp [h, hx])
id                                                        └┘
src  ─┘   └──────────────┘  └┘ └────────┘└───┘  └────┘ └┘  └─
typ  ─┘   └──────────────┘  └┘ └────────┘└───┘  └────┘└┘└┘└─
doc  ─┘   └──────────────┘  └┘ └────────┘ └───┘  └────┘ └┘  └─
txt  ─┘   └──────────────┘  └┘ └────────┘ └───┘  └────┘ └┘  └─
par  ─┘   └──────────────┘  └┘ └────────┘ └───┘  └────┘ └┘  └─
pid  ─┘   └───────────────┘  └┘ └────────┘ └───┘  └─────┘ └┘  └──
st   ────┘└──────────────────────────────────────┘└───────────┘└─
469    (univ_mem_sets' $ λ _, rfl) }
id      └────────────┘        └─┘
src  ─┘ └────────────┘  └──┘└─┘└┘
typ  ─┘ └────────────┘  └──┘└─┘└┘
doc  ─┘                 └──┘   └┘
txt  ─┘                 └──┘   └┘
par  ─┘                 └──┘   └┘
pid  ─┘                 └──┘   
st   ─────────────────────────────┘└┘
470  
471  lemma has_fderiv_at_filter.congr_of_mem_sets (h : has_fderiv_at_filter f f' x L)
id                                                     └──────────────────┘  └┘  
src                                                    └──────────────────┘
typ                                                    └──────────────────┘  └┘  
doc                                                    └──────────────────┘
472    (hL : ∀ᶠ x in L, f₁ x = f x) (hx : f₁ x = f x) : has_fderiv_at_filter f₁ f' x L :=
id           └┘  └┘  └┘            └┘        └──────────────────┘ └┘ └┘  
src          └┘   └┘                                 └──────────────────┘
typ          └┘  └┘  └┘            └┘        └──────────────────┘ └┘ └┘  
doc          └┘   └┘                                   └──────────────────┘
473  begin
st   └─────
474    apply (has_fderiv_at_filter_congr_of_mem_sets hx hL _).2 h,
id            └────────────────────────────────────┘ └┘ └┘      
src    └────┘ └────────────────────────────────────┘    └────┘
typ    └────┘ └────────────────────────────────────┘└┘└┘└────┘
doc    └────┘                                           └────┘
txt    └────┘                                           └────┘
par    └────┘                                           └────┘
pid                                                    └────┘
st   ───────────────────────────────────────────────────────────┘└─
475    exact λx, rfl
id               └─┘
src    └────┘ └─┘└─┘
typ    └────┘ └─┘└─┘
doc    └────┘ └─┘   
txt    └────┘ └─┘   
par    └────┘ └─┘   
pid          └─┘   
st   ───────────────┘
476  end
st   └─┘
477  
478  lemma has_fderiv_within_at.congr_mono (h : has_fderiv_within_at f f' s x) (ht : ∀x ∈ t, f₁ x = f x)
id                                              └──────────────────┘  └┘                └┘    
src                                             └──────────────────┘                              
typ                                             └──────────────────┘  └┘                └┘    
doc                                             └──────────────────┘
479    (hx : f₁ x = f x) (h₁ : t ⊆ s) : has_fderiv_within_at f₁ f' t x :=
id           └┘                  └──────────────────┘ └┘ └┘  
src                                   └──────────────────┘
typ          └┘                  └──────────────────┘ └┘ └┘  
doc                                     └──────────────────┘
480  has_fderiv_at_filter.congr_of_mem_sets (h.mono h₁) (filter.mem_inf_sets_of_right ht) hx
id   └────────────────────────────────────┘  └───┘ └┘   └──────────────────────────┘ └┘  └┘
src  └────────────────────────────────────┘   └───┘      └──────────────────────────┘
typ  └────────────────────────────────────┘  └───┘ └┘   └──────────────────────────┘ └┘  └┘
481  
482  lemma has_fderiv_within_at.congr (h : has_fderiv_within_at f f' s x) (hs : ∀x ∈ s, f₁ x = f x)
id                                         └──────────────────┘  └┘                └┘    
src                                        └──────────────────┘                              
typ                                        └──────────────────┘  └┘                └┘    
doc                                        └──────────────────┘
483    (hx : f₁ x = f x) : has_fderiv_within_at f₁ f' s x :=
id           └┘        └──────────────────┘ └┘ └┘  
src                       └──────────────────┘
typ          └┘        └──────────────────┘ └┘ └┘  
doc                        └──────────────────┘
484  h.congr_mono hs hx (subset.refl _)
id   └─────────┘ └┘ └┘  └─────────┘
src   └─────────┘        └─────────┘
typ  └─────────┘ └┘ └┘  └─────────┘
485  
486  lemma has_fderiv_within_at.congr_of_mem_nhds_within (h : has_fderiv_within_at f f' s x)
id                                                            └──────────────────┘  └┘  
src                                                           └──────────────────┘
typ                                                           └──────────────────┘  └┘  
doc                                                           └──────────────────┘
487    (h₁ : ∀ᶠ y in nhds_within x s, f₁ y = f y) (hx : f₁ x = f x) : has_fderiv_within_at f₁ f' s x :=
id           └┘  └┘ └─────────┘   └┘            └┘        └──────────────────┘ └┘ └┘  
src          └┘   └┘ └─────────┘                                   └──────────────────┘
typ          └┘  └┘ └─────────┘   └┘            └┘        └──────────────────┘ └┘ └┘  
doc          └┘   └┘ └─────────┘                                     └──────────────────┘
488  has_fderiv_at_filter.congr_of_mem_sets h h₁ hx
id   └────────────────────────────────────┘  └┘ └┘
src  └────────────────────────────────────┘
typ  └────────────────────────────────────┘  └┘ └┘
489  
490  lemma has_fderiv_at.congr_of_mem_nhds (h : has_fderiv_at f f' x)
id                                              └───────────┘  └┘ 
src                                             └───────────┘
typ                                             └───────────┘  └┘ 
doc                                             └───────────┘
491    (h₁ : ∀ᶠ y in 𝓝 x, f₁ y = f y) : has_fderiv_at f₁ f' x :=
id           └┘  └┘   └┘        └───────────┘ └┘ └┘ 
src          └┘   └┘                 └───────────┘
typ          └┘  └┘   └┘        └───────────┘ └┘ └┘ 
doc          └┘   └┘                  └───────────┘
492  has_fderiv_at_filter.congr_of_mem_sets h h₁ (mem_of_nhds h₁ : _)
id   └────────────────────────────────────┘  └┘  └─────────┘ └┘
src  └────────────────────────────────────┘       └─────────┘
typ  └────────────────────────────────────┘  └┘  └─────────┘ └┘
493  
494  lemma differentiable_within_at.congr_mono (h : differentiable_within_at 𝕜 f s x)
id                                                  └──────────────────────┘    
src                                                 └──────────────────────┘
typ                                                 └──────────────────────┘    
doc                                                 └──────────────────────┘
495    (ht : ∀x ∈ t, f₁ x = f x) (hx : f₁ x = f x) (h₁ : t ⊆ s) : differentiable_within_at 𝕜 f₁ t x :=
id                 └┘            └┘                  └──────────────────────┘  └┘  
src                                                            └──────────────────────┘
typ                └┘            └┘                  └──────────────────────┘  └┘  
doc                                                               └──────────────────────┘
496  (has_fderiv_within_at.congr_mono h.has_fderiv_within_at ht hx h₁).differentiable_within_at
id    └─────────────────────────────┘ └───────────────────┘ └┘ └┘ └┘ └──────────────────────┘
src   └─────────────────────────────┘  └───────────────────┘          └──────────────────────┘
typ   └─────────────────────────────┘ └───────────────────┘ └┘ └┘ └┘ └──────────────────────┘
497  
498  lemma differentiable_within_at.congr (h : differentiable_within_at 𝕜 f s x)
id                                             └──────────────────────┘    
src                                            └──────────────────────┘
typ                                            └──────────────────────┘    
doc                                            └──────────────────────┘
499    (ht : ∀x ∈ s, f₁ x = f x) (hx : f₁ x = f x) : differentiable_within_at 𝕜 f₁ s x :=
id                 └┘            └┘        └──────────────────────┘  └┘  
src                                                └──────────────────────┘
typ                └┘            └┘        └──────────────────────┘  └┘  
doc                                                  └──────────────────────┘
500  differentiable_within_at.congr_mono h ht hx (subset.refl _)
id   └─────────────────────────────────┘  └┘ └┘  └─────────┘
src  └─────────────────────────────────┘          └─────────┘
typ  └─────────────────────────────────┘  └┘ └┘  └─────────┘
501  
502  lemma differentiable_within_at.congr_of_mem_nhds_within
503    (h : differentiable_within_at 𝕜 f s x) (h₁ : ∀ᶠ y in nhds_within x s, f₁ y = f y)
id          └──────────────────────┘            └┘  └┘ └─────────┘   └┘    
src         └──────────────────────┘                └┘   └┘ └─────────┘          
typ         └──────────────────────┘            └┘  └┘ └─────────┘   └┘    
doc         └──────────────────────┘                └┘   └┘ └─────────┘    
504    (hx : f₁ x = f x) : differentiable_within_at 𝕜 f₁ s x :=
id           └┘        └──────────────────────┘  └┘  
src                       └──────────────────────┘
typ          └┘        └──────────────────────┘  └┘  
doc                        └──────────────────────┘
505  (h.has_fderiv_within_at.congr_of_mem_nhds_within h₁ hx).differentiable_within_at
id    └───────────────────┘└───────────────────────┘ └┘ └┘ └──────────────────────┘
src    └───────────────────┘└───────────────────────┘       └──────────────────────┘
typ   └───────────────────┘└───────────────────────┘ └┘ └┘ └──────────────────────┘
506  
507  lemma differentiable_on.congr_mono (h : differentiable_on 𝕜 f s) (h' : ∀x ∈ t, f₁ x = f x)
id                                           └───────────────┘                 └┘    
src                                          └───────────────┘                           
typ                                          └───────────────┘                 └┘    
doc                                          └───────────────┘
508    (h₁ : t ⊆ s) : differentiable_on 𝕜 f₁ t :=
id                 └───────────────┘  └┘ 
src                  └───────────────┘
typ                └───────────────┘  └┘ 
doc                   └───────────────┘
509  λ x hx, (h x (h₁ hx)).congr_mono h' (h' x hx) h₁
id      └┘      └┘ └┘  └────────┘  └┘  └┘  └┘  └┘
src                       └────────┘
typ     └┘      └┘ └┘  └────────┘  └┘  └┘  └┘  └┘
510  
511  lemma differentiable_on.congr (h : differentiable_on 𝕜 f s) (h' : ∀x ∈ s, f₁ x = f x) :
id                                      └───────────────┘                 └┘    
src                                     └───────────────┘                           
typ                                     └───────────────┘                 └┘    
doc                                     └───────────────┘
512    differentiable_on 𝕜 f₁ s :=
id     └───────────────┘  └┘ 
src    └───────────────┘
typ    └───────────────┘  └┘ 
doc    └───────────────┘
513  λ x hx, (h x hx).congr h' (h' x hx)
id      └┘     └┘ └───┘  └┘  └┘  └┘
src                  └───┘
typ     └┘     └┘ └───┘  └┘  └┘  └┘
514  
515  lemma differentiable_at.congr_of_mem_nhds (h : differentiable_at 𝕜 f x)
id                                                  └───────────────┘   
src                                                 └───────────────┘
typ                                                 └───────────────┘   
doc                                                 └───────────────┘
516    (hL : ∀ᶠ y in 𝓝 x, f₁ y = f y) : differentiable_at 𝕜 f₁ x :=
id           └┘  └┘   └┘        └───────────────┘  └┘ 
src          └┘   └┘                 └───────────────┘
typ          └┘  └┘   └┘        └───────────────┘  └┘ 
doc          └┘   └┘                  └───────────────┘
517  has_fderiv_at.differentiable_at (has_fderiv_at_filter.congr_of_mem_sets h.has_fderiv_at hL (mem_of_nhds hL : _))
id   └─────────────────────────────┘  └────────────────────────────────────┘ └────────────┘ └┘  └─────────┘ └┘
src  └─────────────────────────────┘  └────────────────────────────────────┘  └────────────┘     └─────────┘
typ  └─────────────────────────────┘  └────────────────────────────────────┘ └────────────┘ └┘  └─────────┘ └┘
518  
519  lemma differentiable_within_at.fderiv_within_congr_mono (h : differentiable_within_at 𝕜 f s x)
id                                                                └──────────────────────┘    
src                                                               └──────────────────────┘
typ                                                               └──────────────────────┘    
doc                                                               └──────────────────────┘
520    (hs : ∀x ∈ t, f₁ x = f x) (hx : f₁ x = f x) (hxt : unique_diff_within_at 𝕜 t x) (h₁ : t ⊆ s) :
id                 └┘            └┘             └───────────────────┘             
src                                                     └───────────────────┘                
typ                └┘            └┘             └───────────────────┘             
doc                                                       └───────────────────┘
521    fderiv_within 𝕜 f₁ t x = fderiv_within 𝕜 f s x :=
id     └───────────┘  └┘    └───────────┘    
src    └───────────┘           └───────────┘
typ    └───────────┘  └┘    └───────────┘    
doc    └───────────┘            └───────────┘
522  (has_fderiv_within_at.congr_mono h.has_fderiv_within_at hs hx h₁).fderiv_within hxt
id    └─────────────────────────────┘ └───────────────────┘ └┘ └┘ └┘ └───────────┘  └─┘
src   └─────────────────────────────┘  └───────────────────┘          └───────────┘
typ   └─────────────────────────────┘ └───────────────────┘ └┘ └┘ └┘ └───────────┘  └─┘
523  
524  lemma fderiv_within_congr_of_mem_nhds_within (hs : unique_diff_within_at 𝕜 s x)
id                                                      └───────────────────┘   
src                                                     └───────────────────┘
typ                                                     └───────────────────┘   
doc                                                     └───────────────────┘
525    (hL : ∀ᶠ y in nhds_within x s, f₁ y = f y) (hx : f₁ x = f x) :
id           └┘  └┘ └─────────┘   └┘            └┘    
src          └┘   └┘ └─────────┘                           
typ          └┘  └┘ └─────────┘   └┘            └┘    
doc          └┘   └┘ └─────────┘    
526    fderiv_within 𝕜 f₁ s x = fderiv_within 𝕜 f s x :=
id     └───────────┘  └┘    └───────────┘    
src    └───────────┘           └───────────┘
typ    └───────────┘  └┘    └───────────┘    
doc    └───────────┘            └───────────┘
527  begin
st   └─────
528    by_cases h : differentiable_within_at 𝕜 f s x ∨ differentiable_within_at 𝕜 f₁ s x,
id                                                   └──────────────────────┘  └┘  
src    └───────┘ └─┘                            └──────────────────────┘    
typ    └───────┘ └─┘                           └──────────────────────┘└┘
doc    └───────┘ └─┘                             └──────────────────────┘    
txt    └───────┘ └─┘                                                         
par    └───────┘ └─┘                                                         
pid             └─┘                                                         
st   ──────────────────────────────────────────────────────────────────────────────────┘└─
529    { cases h,
id             
src      └────┘
typ      └────┘
doc      └────┘
txt      └────┘
par      └────┘
pid           
st   ───┘└─────┘└─
530      { apply has_fderiv_within_at.fderiv_within _ hs,
id               └────────────────────────────────┘   └┘
src        └────┘└────────────────────────────────┘└─┘
typ        └────┘└────────────────────────────────┘└─┘└┘
doc        └────┘                                  └─┘
txt        └────┘                                  └─┘
par        └────┘                                  └─┘
pid                                               └─┘
st   ─────┘└───────────────────────────────────────────┘└─
531        exact has_fderiv_at_filter.congr_of_mem_sets h.has_fderiv_within_at hL hx },
id               └────────────────────────────────────┘ └────────────────────┘ └┘ └┘
src        └────┘└────────────────────────────────────┘└────────────────────┘    
typ        └────┘└────────────────────────────────────┘└────────────────────┘└┘└┘
doc        └────┘                                                                
txt        └────┘                                                                
par        └────┘                                                                
pid                                                                             
st   ───────────────────────────────────────────────────────────────────────────────┘└┘
532      { symmetry,
src        └──────┘
typ        └──────┘
doc        └──────┘
txt        └──────┘
par        └──────┘
st   ─────────────┘└─
533        apply has_fderiv_within_at.fderiv_within _ hs,
id               └────────────────────────────────┘   └┘
src        └────┘└────────────────────────────────┘└─┘
typ        └────┘└────────────────────────────────┘└─┘└┘
doc        └────┘                                  └─┘
txt        └────┘                                  └─┘
par        └────┘                                  └─┘
pid                                               └─┘
st   ──────────────────────────────────────────────────┘└─
534        apply has_fderiv_at_filter.congr_of_mem_sets h.has_fderiv_within_at _ hx.symm,
id               └────────────────────────────────────┘ └────────────────────┘   └─────┘
src        └────┘└────────────────────────────────────┘└────────────────────┘└─┘└─────┘
typ        └────┘└────────────────────────────────────┘└────────────────────┘└─┘└─────┘
doc        └────┘                                                            └─┘
txt        └────┘                                                            └─┘
par        └────┘                                                            └─┘
pid                                                                         └─┘
st   ──────────────────────────────────────────────────────────────────────────────────┘└─
535        convert hL,
id                 └┘
src        └──────┘
typ        └──────┘└┘
doc        └──────┘
txt        └──────┘
par        └──────┘
pid               
st   ───────────────┘└─
536        ext y,
src        └───┘
typ        └───┘
doc        └───┘
txt        └───┘
par        └───┘
pid           └┘
st   ──────────┘└─
537        exact eq_comm } },
id               └─────┘
src        └────┘└─────┘
typ        └────┘└─────┘
doc        └────┘       
txt        └────┘       
par        └────┘       
pid                    
st   ───────────────────┘└──┘
538    { push_neg at h,
src      └───────────┘
typ      └───────────┘
doc      └───────────┘
txt      └───────────┘
par      └───────────┘
pid              └───┘
st   ────────────────┘└─
539      have A : fderiv_within 𝕜 f s x = 0,
id                └───────────┘     
src      └───────┘└───────────┘    └┘
typ      └───────┘└───────────┘└┘
doc      └───────┘└───────────┘     └┘
txt      └───────┘                  └┘
par      └───────┘                  └┘
pid      └────┘└─┘                  
st   ─────────────────────────────────────┘
540        by { unfold differentiable_within_at at h, simp [fderiv_within, h] },
id                                                          └───────────┘  
src             └──────────────────────────────────┘  └────┘└───────────┘└┘ └┘
typ             └──────────────────────────────────┘  └────┘└───────────┘└┘└┘
doc             └──────────────────────────────────┘  └────┘└───────────┘└┘ └┘
txt             └──────────────────────────────────┘  └────┘             └┘ └┘
par             └──────────────────────────────────┘  └────┘             └┘ └┘
pid                   └───────────────────────┘└───┘                   └┘ 
st            └───────────────────────────────────┘└────────────────────────┘└┘
541      have A₁ : fderiv_within 𝕜 f₁ s x = 0,
id                 └───────────┘  └┘  
src      └────────┘└───────────┘      └┘
typ      └────────┘└───────────┘└┘ └┘
doc      └────────┘└───────────┘      └┘
txt      └────────┘                   └┘
par      └────────┘                   └┘
pid      └─────┘└─┘                   
st   ───────────────────────────────────────┘
542        by { unfold differentiable_within_at at h, simp [fderiv_within, h] },
id                                                          └───────────┘  
src             └──────────────────────────────────┘  └────┘└───────────┘└┘ └┘
typ             └──────────────────────────────────┘  └────┘└───────────┘└┘└┘
doc             └──────────────────────────────────┘  └────┘└───────────┘└┘ └┘
txt             └──────────────────────────────────┘  └────┘             └┘ └┘
par             └──────────────────────────────────┘  └────┘             └┘ └┘
pid                   └───────────────────────┘└───┘                   └┘ 
st            └───────────────────────────────────┘└────────────────────────┘└┘
543      rw [A, A₁] }
id             └┘
src      └──┘ └┘  └┘
typ      └──┘└┘└┘└┘
doc      └──┘ └┘  └┘
txt      └──┘ └┘  └┘
par      └──┘ └┘  └┘
pid        └┘ └┘  
st   ────────┘└──┘└─
544  end
st   ──┘
545  
546  lemma fderiv_within_congr (hs : unique_diff_within_at 𝕜 s x)
id                                   └───────────────────┘   
src                                  └───────────────────┘
typ                                  └───────────────────┘   
doc                                  └───────────────────┘
547    (hL : ∀y∈s, f₁ y = f y) (hx : f₁ x = f x) :
id               └┘            └┘    
src                                      
typ              └┘            └┘    
548    fderiv_within 𝕜 f₁ s x = fderiv_within 𝕜 f s x :=
id     └───────────┘  └┘    └───────────┘    
src    └───────────┘           └───────────┘
typ    └───────────┘  └┘    └───────────┘    
doc    └───────────┘            └───────────┘
549  begin
st   └─────
550    apply fderiv_within_congr_of_mem_nhds_within hs _ hx,
id           └────────────────────────────────────┘ └┘   └┘
src    └────┘└────────────────────────────────────┘  └─┘
typ    └────┘└────────────────────────────────────┘└┘└─┘└┘
doc    └────┘                                        └─┘
txt    └────┘                                        └─┘
par    └────┘                                        └─┘
pid                                                 └─┘
st   ─────────────────────────────────────────────────────┘└─
551    apply mem_sets_of_superset self_mem_nhds_within,
id           └──────────────────┘ └──────────────────┘
src    └────┘└──────────────────┘└──────────────────┘
typ    └────┘└──────────────────┘└──────────────────┘
doc    └────┘                    
txt    └────┘                    
par    └────┘                    
pid                             
st   ────────────────────────────────────────────────┘└─
552    exact hL
id           └┘
src    └────┘  
typ    └────┘└┘
doc    └────┘  
txt    └────┘  
par    └────┘  
pid           
st   ──────────┘
553  end
st   └─┘
554  
555  lemma fderiv_congr_of_mem_nhds (hL : ∀ᶠ y in 𝓝 x, f₁ y = f y) :
id                                        └┘  └┘   └┘    
src                                       └┘   └┘         
typ                                       └┘  └┘   └┘    
doc                                       └┘   └┘   
556    fderiv 𝕜 f₁ x = fderiv 𝕜 f x :=
id     └────┘  └┘   └────┘   
src    └────┘         └────┘
typ    └────┘  └┘   └────┘   
doc    └────┘          └────┘
557  begin
st   └─────
558    have A : f₁ x = f x := (mem_of_nhds hL : _),
id              └┘          └─────────┘ └┘
src    └───────┘     └──┘ └─────────┘  └───┘
typ    └───────┘└┘ └──┘ └─────────┘└┘└───┘
doc    └───────┘      └──┘              └───┘
txt    └───────┘      └──┘              └───┘
par    └───────┘      └──┘              └───┘
pid    └────┘└─┘      └──┘              └───┘
st   ────────────────────────────────────────────┘└─
559    rw [← fderiv_within_univ, ← fderiv_within_univ],
id           └────────────────┘    └────────────────┘
src    └────┘└────────────────┘└──┘└────────────────┘
typ    └────┘└────────────────┘└──┘└────────────────┘
doc    └────┘                  └──┘                  
txt    └────┘                  └──┘                  
par    └────┘                  └──┘                  
pid      └──┘                  └──┘                  
st   ─────────────────────────┘└────────────────────┘└──
560    rw ← nhds_within_univ at hL,
id          └──────────────┘
src    └───┘└──────────────┘└────┘
typ    └───┘└──────────────┘└────┘
doc    └───┘                └────┘
txt    └───┘                └────┘
par    └───┘                └────┘
pid      └─┘                └────┘
st   ────────────────────────────┘└─
561    exact fderiv_within_congr_of_mem_nhds_within unique_diff_within_at_univ hL A
id           └────────────────────────────────────┘ └────────────────────────┘ └┘ 
src    └────┘└────────────────────────────────────┘└────────────────────────┘   
typ    └────┘└────────────────────────────────────┘└────────────────────────┘└┘
doc    └────┘                                                                   
txt    └────┘                                                                   
par    └────┘                                                                   
pid                                                                            
st   ──────────────────────────────────────────────────────────────────────────────┘
562  end
st   └─┘
563  
564  end congr
565  
566  section id
567  /-! ### Derivative of the identity -/
568  
569  theorem has_fderiv_at_filter_id (x : E) (L : filter E) :
id                                               └────┘ 
src                                               └────┘
typ                                              └────┘ 
570    has_fderiv_at_filter id (id : E →L[𝕜] E) x L :=
id     └──────────────────┘ └┘  └┘    └─┘    
src    └──────────────────┘ └┘  └┘     └─┘ 
typ    └──────────────────┘ └┘  └┘    └─┘    
doc    └──────────────────┘     └┘     └─┘ 
571  (is_o_zero _ _).congr_left $ by simp
id    └───────┘     └────────┘
src   └───────┘     └────────┘       └────
typ   └───────┘     └────────┘       └────
doc                                  └────
txt                                  └────
par                                  └────
pid                                      
st                                  └─────
572  
src  
typ  
doc  
txt  
par  
pid  
st   
573  theorem has_fderiv_within_at_id (x : E) (s : set E) :
id                                               └─┘ 
src                                               └─┘
typ                                              └─┘ 
574    has_fderiv_within_at id (id : E →L[𝕜] E) s x :=
id     └──────────────────┘ └┘  └┘    └─┘    
src    └──────────────────┘ └┘  └┘     └─┘ 
typ    └──────────────────┘ └┘  └┘    └─┘    
doc    └──────────────────┘     └┘     └─┘ 
575  has_fderiv_at_filter_id _ _
id   └─────────────────────┘
src  └─────────────────────┘
typ  └─────────────────────┘
576  
577  theorem has_fderiv_at_id (x : E) : has_fderiv_at id (id : E →L[𝕜] E) x :=
id                                     └───────────┘ └┘  └┘    └─┘   
src                                     └───────────┘ └┘  └┘     └─┘ 
typ                                    └───────────┘ └┘  └┘    └─┘   
doc                                     └───────────┘     └┘     └─┘ 
578  has_fderiv_at_filter_id _ _
id   └─────────────────────┘
src  └─────────────────────┘
typ  └─────────────────────┘
579  
580  lemma differentiable_at_id : differentiable_at 𝕜 id x :=
id                                └───────────────┘  └┘ 
src                               └───────────────┘   └┘
typ                               └───────────────┘  └┘ 
doc                               └───────────────┘
581  (has_fderiv_at_id x).differentiable_at
id    └──────────────┘  └───────────────┘
src   └──────────────┘   └───────────────┘
typ   └──────────────┘  └───────────────┘
582  
583  lemma differentiable_within_at_id : differentiable_within_at 𝕜 id s x :=
id                                       └──────────────────────┘  └┘  
src                                      └──────────────────────┘   └┘
typ                                      └──────────────────────┘  └┘  
doc                                      └──────────────────────┘
584  differentiable_at_id.differentiable_within_at
id   └──────────────────┘└───────────────────────┘
src  └──────────────────┘└───────────────────────┘
typ  └──────────────────┘└───────────────────────┘
585  
586  lemma differentiable_id : differentiable 𝕜 (id : E → E) :=
id                             └────────────┘   └┘      
src                            └────────────┘    └┘
typ                            └────────────┘   └┘      
doc                            └────────────┘
587  λx, differentiable_at_id
id      └──────────────────┘
src      └──────────────────┘
typ     └──────────────────┘
588  
589  lemma differentiable_on_id : differentiable_on 𝕜 id s :=
id                                └───────────────┘  └┘ 
src                               └───────────────┘   └┘
typ                               └───────────────┘  └┘ 
doc                               └───────────────┘
590  differentiable_id.differentiable_on
id   └───────────────┘└────────────────┘
src  └───────────────┘└────────────────┘
typ  └───────────────┘└────────────────┘
591  
592  lemma fderiv_id : fderiv 𝕜 id x = id :=
id                     └────┘  └┘   └┘
src                    └────┘   └┘    └┘
typ                    └────┘  └┘   └┘
doc                    └────┘          └┘
593  has_fderiv_at.fderiv (has_fderiv_at_id x)
id   └──────────────────┘  └──────────────┘ 
src  └──────────────────┘  └──────────────┘
typ  └──────────────────┘  └──────────────┘ 
594  
595  lemma fderiv_within_id (hxs : unique_diff_within_at 𝕜 s x) :
id                                 └───────────────────┘   
src                                └───────────────────┘
typ                                └───────────────────┘   
doc                                └───────────────────┘
596    fderiv_within 𝕜 id s x = id :=
id     └───────────┘  └┘    └┘
src    └───────────┘   └┘      └┘
typ    └───────────┘  └┘    └┘
doc    └───────────┘            └┘
597  begin
st   └─────
598    rw differentiable_at.fderiv_within (differentiable_at_id) hxs,
id        └─────────────────────────────┘  └──────────────────┘  └─┘
src    └─┘└─────────────────────────────┘ └──────────────────┘└┘
typ    └─┘└─────────────────────────────┘ └──────────────────┘└┘└─┘
doc    └─┘                                                    └┘
txt    └─┘                                                    └┘
par    └─┘                                                    └┘
pid                                                          └┘
st   ──────────────────────────────────────────────────────────────┘└─
599    exact fderiv_id
id           └───────┘
src    └────┘└───────┘
typ    └────┘└───────┘
doc    └────┘         
txt    └────┘         
par    └────┘         
pid                  
st   ─────────────────┘
600  end
st   └─┘
601  
602  end id
603  
604  section const
605  /-! ### derivative of a constant function -/
606  
607  theorem has_fderiv_at_filter_const (c : F) (x : E) (L : filter E) :
id                                                         └────┘ 
src                                                          └────┘
typ                                                        └────┘ 
608    has_fderiv_at_filter (λ x, c) (0 : E →L[𝕜] F) x L :=
id     └──────────────────┘              └─┘    
src    └──────────────────┘                 └─┘ 
typ    └──────────────────┘              └─┘    
doc    └──────────────────┘                 └─┘ 
609  (is_o_zero _ _).congr_left $ λ _, by simp only [zero_apply, sub_self]
id    └───────┘     └────────┘                      └────────┘  └──────┘
src   └───────┘     └────────┘            └─────────┘└────────┘└┘└──────┘└─
typ   └───────┘     └────────┘           └─────────┘└────────┘└┘└──────┘└─
doc                                       └─────────┘          └┘        └─
txt                                       └─────────┘          └┘        └─
par                                       └─────────┘          └┘        └─
pid                                           └──┘└┘          └┘        
st                                       └─────────────────────────────────
610  
src  
typ  
doc  
txt  
par  
pid  
st   
611  theorem has_fderiv_within_at_const (c : F) (x : E) (s : set E) :
id                                                         └─┘ 
src                                                          └─┘
typ                                                        └─┘ 
612    has_fderiv_within_at (λ x, c) (0 : E →L[𝕜] F) s x :=
id     └──────────────────┘              └─┘    
src    └──────────────────┘                 └─┘ 
typ    └──────────────────┘              └─┘    
doc    └──────────────────┘                 └─┘ 
613  has_fderiv_at_filter_const _ _ _
id   └────────────────────────┘
src  └────────────────────────┘
typ  └────────────────────────┘
614  
615  theorem has_fderiv_at_const (c : F) (x : E) :
id                                           
typ                                          
616    has_fderiv_at (λ x, c) (0 : E →L[𝕜] F) x :=
id     └───────────┘              └─┘   
src    └───────────┘                 └─┘ 
typ    └───────────┘              └─┘   
doc    └───────────┘                 └─┘ 
617  has_fderiv_at_filter_const _ _ _
id   └────────────────────────┘
src  └────────────────────────┘
typ  └────────────────────────┘
618  
619  lemma differentiable_at_const (c : F) : differentiable_at 𝕜 (λx, c) x :=
id                                          └───────────────┘        
src                                          └───────────────┘
typ                                         └───────────────┘        
doc                                          └───────────────┘
620  ⟨0, has_fderiv_at_const c x⟩
id       └─────────────────┘  
src      └─────────────────┘
typ      └─────────────────┘  
621  
622  lemma differentiable_within_at_const (c : F) : differentiable_within_at 𝕜 (λx, c) s x :=
id                                                 └──────────────────────┘         
src                                                 └──────────────────────┘
typ                                                └──────────────────────┘         
doc                                                 └──────────────────────┘
623  differentiable_at.differentiable_within_at (differentiable_at_const _)
id   └────────────────────────────────────────┘  └─────────────────────┘
src  └────────────────────────────────────────┘  └─────────────────────┘
typ  └────────────────────────────────────────┘  └─────────────────────┘
624  
625  lemma fderiv_const (c : F) : fderiv 𝕜 (λy, c) x = 0 :=
id                               └────┘         
src                               └────┘             
typ                              └────┘         
doc                               └────┘
626  has_fderiv_at.fderiv (has_fderiv_at_const c x)
id   └──────────────────┘  └─────────────────┘  
src  └──────────────────┘  └─────────────────┘
typ  └──────────────────┘  └─────────────────┘  
627  
628  lemma fderiv_within_const (c : F) (hxs : unique_diff_within_at 𝕜 s x) :
id                                           └───────────────────┘   
src                                           └───────────────────┘
typ                                          └───────────────────┘   
doc                                           └───────────────────┘
629    fderiv_within 𝕜 (λy, c) s x = 0 :=
id     └───────────┘          
src    └───────────┘               
typ    └───────────┘          
doc    └───────────┘
630  begin
st   └─────
631    rw differentiable_at.fderiv_within (differentiable_at_const _) hxs,
id        └─────────────────────────────┘  └─────────────────────┘    └─┘
src    └─┘└─────────────────────────────┘ └─────────────────────┘└──┘
typ    └─┘└─────────────────────────────┘ └─────────────────────┘└──┘└─┘
doc    └─┘                                                       └──┘
txt    └─┘                                                       └──┘
par    └─┘                                                       └──┘
pid                                                             └──┘
st   ───────────────────────────────────────────────────────────────────┘└─
632    exact fderiv_const _
id           └──────────┘
src    └────┘└──────────┘└─┘
typ    └────┘└──────────┘└─┘
doc    └────┘            └─┘
txt    └────┘            └─┘
par    └────┘            └─┘
pid                     └┘
st   ──────────────────────┘
633  end
st   └─┘
634  
635  lemma differentiable_const (c : F) : differentiable 𝕜 (λx : E, c) :=
id                                       └────────────┘          
src                                       └────────────┘
typ                                      └────────────┘          
doc                                       └────────────┘
636  λx, differentiable_at_const _
id      └─────────────────────┘
src      └─────────────────────┘
typ     └─────────────────────┘
637  
638  lemma differentiable_on_const (c : F) : differentiable_on 𝕜 (λx, c) s :=
id                                          └───────────────┘        
src                                          └───────────────┘
typ                                         └───────────────┘        
doc                                          └───────────────┘
639  (differentiable_const _).differentiable_on
id    └──────────────────┘   └───────────────┘
src   └──────────────────┘   └───────────────┘
typ   └──────────────────┘   └───────────────┘
640  
641  end const
642  
643  section continuous_linear_map
644  /-! ### Continuous linear maps
645  
646  There are currently two variants of these in mathlib, the bundled version
647  (named `continuous_linear_map`, and denoted `E →L[𝕜] F`), and the unbundled version (with a
648  predicate `is_bounded_linear_map`). We give statements for both versions. -/
649  
650  lemma is_bounded_linear_map.has_fderiv_at_filter (h : is_bounded_linear_map 𝕜 f) :
id                                                         └───────────────────┘  
src                                                        └───────────────────┘
typ                                                        └───────────────────┘  
doc                                                        └───────────────────┘
651    has_fderiv_at_filter f h.to_continuous_linear_map x L :=
id     └──────────────────┘  └───────────────────────┘  
src    └──────────────────┘    └───────────────────────┘
typ    └──────────────────┘  └───────────────────────┘  
doc    └──────────────────┘    └───────────────────────┘
652  begin
st   └─────
653    have : (λ (x' : E), f x' - f x - h.to_continuous_linear_map (x' - x)) = λx', 0,
id                                   └────────────────────────┘          
src    └─────┘  └─────┘ └─┘      └────────────────────────┘     └─┘ └───┘
typ    └─────┘  └─────┘└─┘     └────────────────────────┘    └─┘ └───┘
doc    └─────┘  └─────┘ └─┘       └────────────────────────┘     └─┘  └───┘
txt    └─────┘  └─────┘ └─┘                                      └─┘  └───┘
par    └─────┘  └─────┘ └─┘                                      └─┘  └───┘
pid    └───┘└┘  └─────┘ └─┘                                      └─┘  └──┘
st   ───────────────────────────────────────────────────────────────────────────────┘└─
654    { ext,
src      └─┘
typ      └─┘
doc      └─┘
txt      └─┘
par      └─┘
st   ───┘└─┘└─
655      have : ∀a, h.to_continuous_linear_map a = f a := λa, rfl,
id                  └────────────────────────┘               └─┘
src      └─────┘  └────────────────────────┘    └──┘ └─┘└─┘
typ      └─────┘  └────────────────────────┘   └──┘ └─┘└─┘
doc      └─────┘  └────────────────────────┘    └──┘ └─┘
txt      └─────┘                                └──┘ └─┘
par      └─────┘                                └──┘ └─┘
pid      └───┘└┘                                └──┘ └─┘
st   ───────────────────────────────────────────────────────────┘└─
656      simp,
src      └──┘
typ      └──┘
doc      └──┘
txt      └──┘
par      └──┘
st   ───────┘└─
657      simp [this] },
id             └──┘
src      └────┘    └┘
typ      └────┘└──┘└┘
doc      └────┘    └┘
txt      └────┘    └┘
par      └────┘    └┘
pid              
st   ───────────────┘└┘
658    rw [has_fderiv_at_filter, this],
id         └──────────────────┘  └──┘
src    └──┘└──────────────────┘└┘    
typ    └──┘└──────────────────┘└┘└──┘
doc    └──┘└──────────────────┘└┘    
txt    └──┘                    └┘    
par    └──┘                    └┘    
pid      └┘                    └┘    
st   ─────────────────────────┘└────┘└──
659    exact asymptotics.is_o_zero _ _
id           └───────────────────┘
src    └────┘└───────────────────┘└───┘
typ    └────┘└───────────────────┘└───┘
doc    └────┘                     └───┘
txt    └────┘                     └───┘
par    └────┘                     └───┘
pid                              └──┘
st   ─────────────────────────────────┘
660  end
st   └─┘
661  
662  lemma is_bounded_linear_map.has_fderiv_within_at (h : is_bounded_linear_map 𝕜 f) :
id                                                         └───────────────────┘  
src                                                        └───────────────────┘
typ                                                        └───────────────────┘  
doc                                                        └───────────────────┘
663    has_fderiv_within_at f h.to_continuous_linear_map s x :=
id     └──────────────────┘  └───────────────────────┘  
src    └──────────────────┘    └───────────────────────┘
typ    └──────────────────┘  └───────────────────────┘  
doc    └──────────────────┘    └───────────────────────┘
664  h.has_fderiv_at_filter
id   └───────────────────┘
src   └───────────────────┘
typ  └───────────────────┘
665  
666  lemma is_bounded_linear_map.has_fderiv_at (h : is_bounded_linear_map 𝕜 f) :
id                                                  └───────────────────┘  
src                                                 └───────────────────┘
typ                                                 └───────────────────┘  
doc                                                 └───────────────────┘
667    has_fderiv_at f h.to_continuous_linear_map x  :=
id     └───────────┘  └───────────────────────┘ 
src    └───────────┘    └───────────────────────┘
typ    └───────────┘  └───────────────────────┘ 
doc    └───────────┘    └───────────────────────┘
668  h.has_fderiv_at_filter
id   └───────────────────┘
src   └───────────────────┘
typ  └───────────────────┘
669  
670  lemma is_bounded_linear_map.differentiable_at (h : is_bounded_linear_map 𝕜 f) :
id                                                      └───────────────────┘  
src                                                     └───────────────────┘
typ                                                     └───────────────────┘  
doc                                                     └───────────────────┘
671    differentiable_at 𝕜 f x :=
id     └───────────────┘   
src    └───────────────┘
typ    └───────────────┘   
doc    └───────────────┘
672  h.has_fderiv_at.differentiable_at
id   └────────────┘└────────────────┘
src   └────────────┘└────────────────┘
typ  └────────────┘└────────────────┘
673  
674  lemma is_bounded_linear_map.differentiable_within_at (h : is_bounded_linear_map 𝕜 f) :
id                                                             └───────────────────┘  
src                                                            └───────────────────┘
typ                                                            └───────────────────┘  
doc                                                            └───────────────────┘
675    differentiable_within_at 𝕜 f s x :=
id     └──────────────────────┘    
src    └──────────────────────┘
typ    └──────────────────────┘    
doc    └──────────────────────┘
676  h.differentiable_at.differentiable_within_at
id   └────────────────┘└───────────────────────┘
src   └────────────────┘└───────────────────────┘
typ  └────────────────┘└───────────────────────┘
677  
678  lemma is_bounded_linear_map.fderiv (h : is_bounded_linear_map 𝕜 f) :
id                                           └───────────────────┘  
src                                          └───────────────────┘
typ                                          └───────────────────┘  
doc                                          └───────────────────┘
679    fderiv 𝕜 f x = h.to_continuous_linear_map :=
id     └────┘     └───────────────────────┘
src    └────┘         └───────────────────────┘
typ    └────┘     └───────────────────────┘
doc    └────┘          └───────────────────────┘
680  has_fderiv_at.fderiv (h.has_fderiv_at)
id   └──────────────────┘  └────────────┘
src  └──────────────────┘   └────────────┘
typ  └──────────────────┘  └────────────┘
681  
682  lemma is_bounded_linear_map.fderiv_within (h : is_bounded_linear_map 𝕜 f)
id                                                  └───────────────────┘  
src                                                 └───────────────────┘
typ                                                 └───────────────────┘  
doc                                                 └───────────────────┘
683    (hxs : unique_diff_within_at 𝕜 s x) : fderiv_within 𝕜 f s x = h.to_continuous_linear_map :=
id            └───────────────────┘       └───────────┘      └───────────────────────┘
src           └───────────────────┘          └───────────┘           └───────────────────────┘
typ           └───────────────────┘       └───────────┘      └───────────────────────┘
doc           └───────────────────┘          └───────────┘            └───────────────────────┘
684  begin
st   └─────
685    rw differentiable_at.fderiv_within h.differentiable_at hxs,
id        └─────────────────────────────┘ └─────────────────┘ └─┘
src    └─┘└─────────────────────────────┘└─────────────────┘
typ    └─┘└─────────────────────────────┘└─────────────────┘└─┘
doc    └─┘                                                  
txt    └─┘                                                  
par    └─┘                                                  
pid                                                        
st   ───────────────────────────────────────────────────────────┘└─
686    exact h.fderiv
id           └──────┘
src    └────┘└──────┘
typ    └────┘└──────┘
doc    └────┘        
txt    └────┘        
par    └────┘        
pid                 
st   ────────────────┘
687  end
st   └─┘
688  
689  lemma is_bounded_linear_map.differentiable (h : is_bounded_linear_map 𝕜 f) :
id                                                   └───────────────────┘  
src                                                  └───────────────────┘
typ                                                  └───────────────────┘  
doc                                                  └───────────────────┘
690    differentiable 𝕜 f :=
id     └────────────┘  
src    └────────────┘
typ    └────────────┘  
doc    └────────────┘
691  λx, h.differentiable_at
id      └────────────────┘
src       └────────────────┘
typ     └────────────────┘
692  
693  lemma is_bounded_linear_map.differentiable_on (h : is_bounded_linear_map 𝕜 f) :
id                                                      └───────────────────┘  
src                                                     └───────────────────┘
typ                                                     └───────────────────┘  
doc                                                     └───────────────────┘
694    differentiable_on 𝕜 f s :=
id     └───────────────┘   
src    └───────────────┘
typ    └───────────────┘   
doc    └───────────────┘
695  h.differentiable.differentiable_on
id   └─────────────┘└────────────────┘
src   └─────────────┘└────────────────┘
typ  └─────────────┘└────────────────┘
696  
697  lemma continuous_linear_map.has_fderiv_at_filter :
698    has_fderiv_at_filter e e x L :=
id     └──────────────────┘    
src    └──────────────────┘
typ    └──────────────────┘    
doc    └──────────────────┘
699  begin
st   └─────
700    have : (λ (x' : E), e x' - e x - e (x' - x)) = λx', 0, by { ext, simp },
id                                              
src    └─────┘  └─────┘ └─┘            └─┘ └───┘       └─┘  └───┘
typ    └─────┘  └─────┘└─┘          └─┘ └───┘       └─┘  └───┘
doc    └─────┘  └─────┘ └─┘             └─┘  └───┘       └─┘  └───┘
txt    └─────┘  └─────┘ └─┘             └─┘  └───┘       └─┘  └───┘
par    └─────┘  └─────┘ └─┘             └─┘  └───┘       └─┘  └───┘
pid    └───┘└┘  └─────┘ └─┘             └─┘  └──┘                
st   ──────────────────────────────────────────────────────┘     └──┘└─────┘└┘
701    rw [has_fderiv_at_filter, this],
id         └──────────────────┘  └──┘
src    └──┘└──────────────────┘└┘    
typ    └──┘└──────────────────┘└┘└──┘
doc    └──┘└──────────────────┘└┘    
txt    └──┘                    └┘    
par    └──┘                    └┘    
pid      └┘                    └┘    
st   ─────────────────────────┘└────┘└──
702    exact asymptotics.is_o_zero _ _
id           └───────────────────┘
src    └────┘└───────────────────┘└───┘
typ    └────┘└───────────────────┘└───┘
doc    └────┘                     └───┘
txt    └────┘                     └───┘
par    └────┘                     └───┘
pid                              └──┘
st   ─────────────────────────────────┘
703  end
st   └─┘
704  
705  protected lemma continuous_linear_map.has_fderiv_within_at : has_fderiv_within_at e e s x :=
id                                                                └──────────────────┘    
src                                                               └──────────────────┘
typ                                                               └──────────────────┘    
doc                                                               └──────────────────┘
706  e.has_fderiv_at_filter
id   └───────────────────┘
src   └───────────────────┘
typ  └───────────────────┘
707  
708  protected lemma continuous_linear_map.has_fderiv_at : has_fderiv_at e e x  :=
id                                                         └───────────┘   
src                                                        └───────────┘
typ                                                        └───────────┘   
doc                                                        └───────────┘
709  e.has_fderiv_at_filter
id   └───────────────────┘
src   └───────────────────┘
typ  └───────────────────┘
710  
711  protected lemma continuous_linear_map.differentiable_at : differentiable_at 𝕜 e x :=
id                                                             └───────────────┘   
src                                                            └───────────────┘
typ                                                            └───────────────┘   
doc                                                            └───────────────┘
712  e.has_fderiv_at.differentiable_at
id   └────────────┘└────────────────┘
src   └────────────┘└────────────────┘
typ  └────────────┘└────────────────┘
713  
714  protected lemma continuous_linear_map.differentiable_within_at : differentiable_within_at 𝕜 e s x :=
id                                                                    └──────────────────────┘    
src                                                                   └──────────────────────┘
typ                                                                   └──────────────────────┘    
doc                                                                   └──────────────────────┘
715  e.differentiable_at.differentiable_within_at
id   └────────────────┘└───────────────────────┘
src   └────────────────┘└───────────────────────┘
typ  └────────────────┘└───────────────────────┘
716  
717  protected lemma continuous_linear_map.fderiv : fderiv 𝕜 e x = e :=
id                                                  └────┘     
src                                                 └────┘       
typ                                                 └────┘     
doc                                                 └────┘
718  e.has_fderiv_at.fderiv
id   └────────────┘└─────┘
src   └────────────┘└─────┘
typ  └────────────┘└─────┘
719  
720  protected lemma continuous_linear_map.fderiv_within (hxs : unique_diff_within_at 𝕜 s x) :
id                                                              └───────────────────┘   
src                                                             └───────────────────┘
typ                                                             └───────────────────┘   
doc                                                             └───────────────────┘
721    fderiv_within 𝕜 e s x = e :=
id     └───────────┘      
src    └───────────┘         
typ    └───────────┘      
doc    └───────────┘
722  begin
st   └─────
723    rw differentiable_at.fderiv_within e.differentiable_at hxs,
id        └─────────────────────────────┘ └─────────────────┘ └─┘
src    └─┘└─────────────────────────────┘└─────────────────┘
typ    └─┘└─────────────────────────────┘└─────────────────┘└─┘
doc    └─┘                                                  
txt    └─┘                                                  
par    └─┘                                                  
pid                                                        
st   ───────────────────────────────────────────────────────────┘└─
724    exact e.fderiv
id           └──────┘
src    └────┘└──────┘
typ    └────┘└──────┘
doc    └────┘        
txt    └────┘        
par    └────┘        
pid                 
st   ────────────────┘
725  end
st   └─┘
726  
727  protected lemma continuous_linear_map.differentiable : differentiable 𝕜 e :=
id                                                          └────────────┘  
src                                                         └────────────┘
typ                                                         └────────────┘  
doc                                                         └────────────┘
728  λx, e.differentiable_at
id      └────────────────┘
src       └────────────────┘
typ     └────────────────┘
729  
730  protected lemma continuous_linear_map.differentiable_on : differentiable_on 𝕜 e s :=
id                                                             └───────────────┘   
src                                                            └───────────────┘
typ                                                            └───────────────┘   
doc                                                            └───────────────┘
731  e.differentiable.differentiable_on
id   └─────────────┘└────────────────┘
src   └─────────────┘└────────────────┘
typ  └─────────────┘└────────────────┘
732  
733  end continuous_linear_map
734  
735  section const_smul
736  /-! ### Derivative of a function multiplied by a constant -/
737  theorem has_fderiv_at_filter.const_smul (h : has_fderiv_at_filter f f' x L) (c : 𝕜) :
id                                                └──────────────────┘  └┘         
src                                               └──────────────────┘
typ                                               └──────────────────┘  └┘         
doc                                               └──────────────────┘
738    has_fderiv_at_filter (λ x, c • f x) (c • f') x L :=
id     └──────────────────┘              └┘   
src    └──────────────────┘                  
typ    └──────────────────┘              └┘   
doc    └──────────────────┘
739  (is_o_const_smul_left h c).congr_left $ λ x, by simp [smul_neg, smul_add]
id    └──────────────────┘   └────────┘                 └──────┘  └──────┘
src   └──────────────────┘     └────────┘            └────┘└──────┘└┘└──────┘└─
typ   └──────────────────┘   └────────┘           └────┘└──────┘└┘└──────┘└─
doc                                                  └────┘        └┘        └─
txt                                                  └────┘        └┘        └─
par                                                  └────┘        └┘        └─
pid                                                              └┘        
st                                                  └──────────────────────────
740  
src  
typ  
doc  
txt  
par  
pid  
st   
741  theorem has_fderiv_within_at.const_smul (h : has_fderiv_within_at f f' s x) (c : 𝕜) :
id                                                └──────────────────┘  └┘         
src                                               └──────────────────┘
typ                                               └──────────────────┘  └┘         
doc                                               └──────────────────┘
742    has_fderiv_within_at (λ x, c • f x) (c • f') s x :=
id     └──────────────────┘              └┘   
src    └──────────────────┘                  
typ    └──────────────────┘              └┘   
doc    └──────────────────┘
743  h.const_smul c
id   └─────────┘ 
src   └─────────┘
typ  └─────────┘ 
744  
745  theorem has_fderiv_at.const_smul (h : has_fderiv_at f f' x) (c : 𝕜) :
id                                         └───────────┘  └┘        
src                                        └───────────┘
typ                                        └───────────┘  └┘        
doc                                        └───────────┘
746    has_fderiv_at (λ x, c • f x) (c • f') x :=
id     └───────────┘              └┘  
src    └───────────┘                  
typ    └───────────┘              └┘  
doc    └───────────┘
747  h.const_smul c
id   └─────────┘ 
src   └─────────┘
typ  └─────────┘ 
748  
749  lemma differentiable_within_at.const_smul (h : differentiable_within_at 𝕜 f s x) (c : 𝕜) :
id                                                  └──────────────────────┘           
src                                                 └──────────────────────┘
typ                                                 └──────────────────────┘           
doc                                                 └──────────────────────┘
750    differentiable_within_at 𝕜 (λy, c • f y) s x :=
id     └──────────────────────┘            
src    └──────────────────────┘          
typ    └──────────────────────┘            
doc    └──────────────────────┘
751  (h.has_fderiv_within_at.const_smul c).differentiable_within_at
id    └───────────────────┘└─────────┘  └──────────────────────┘
src    └───────────────────┘└─────────┘   └──────────────────────┘
typ   └───────────────────┘└─────────┘  └──────────────────────┘
752  
753  lemma differentiable_at.const_smul (h : differentiable_at 𝕜 f x) (c : 𝕜) :
id                                           └───────────────┘          
src                                          └───────────────┘
typ                                          └───────────────┘          
doc                                          └───────────────┘
754    differentiable_at 𝕜 (λy, c • f y) x :=
id     └───────────────┘           
src    └───────────────┘          
typ    └───────────────┘           
doc    └───────────────┘
755  (h.has_fderiv_at.const_smul c).differentiable_at
id    └────────────┘└─────────┘  └───────────────┘
src    └────────────┘└─────────┘   └───────────────┘
typ   └────────────┘└─────────┘  └───────────────┘
756  
757  lemma differentiable_on.const_smul (h : differentiable_on 𝕜 f s) (c : 𝕜) :
id                                           └───────────────┘          
src                                          └───────────────┘
typ                                          └───────────────┘          
doc                                          └───────────────┘
758    differentiable_on 𝕜 (λy, c • f y) s :=
id     └───────────────┘           
src    └───────────────┘          
typ    └───────────────┘           
doc    └───────────────┘
759  λx hx, (h x hx).const_smul c
id     └┘     └┘ └────────┘  
src                 └────────┘
typ    └┘     └┘ └────────┘  
760  
761  lemma differentiable.const_smul (h : differentiable 𝕜 f) (c : 𝕜) :
id                                        └────────────┘         
src                                       └────────────┘
typ                                       └────────────┘         
doc                                       └────────────┘
762    differentiable 𝕜 (λy, c • f y) :=
id     └────────────┘         
src    └────────────┘          
typ    └────────────┘         
doc    └────────────┘
763  λx, (h x).const_smul c
id         └────────┘  
src           └────────┘
typ        └────────┘  
764  
765  lemma fderiv_within_const_smul (hxs : unique_diff_within_at 𝕜 s x)
id                                         └───────────────────┘   
src                                        └───────────────────┘
typ                                        └───────────────────┘   
doc                                        └───────────────────┘
766    (h : differentiable_within_at 𝕜 f s x) (c : 𝕜) :
id          └──────────────────────┘           
src         └──────────────────────┘
typ         └──────────────────────┘           
doc         └──────────────────────┘
767    fderiv_within 𝕜 (λy, c • f y) s x = c • fderiv_within 𝕜 f s x :=
id     └───────────┘                └───────────┘    
src    └───────────┘                        └───────────┘
typ    └───────────┘                └───────────┘    
doc    └───────────┘                           └───────────┘
768  (h.has_fderiv_within_at.const_smul c).fderiv_within hxs
id    └───────────────────┘└─────────┘  └───────────┘  └─┘
src    └───────────────────┘└─────────┘   └───────────┘
typ   └───────────────────┘└─────────┘  └───────────┘  └─┘
769  
770  lemma fderiv_const_smul (h : differentiable_at 𝕜 f x) (c : 𝕜) :
id                                └───────────────┘          
src                               └───────────────┘
typ                               └───────────────┘          
doc                               └───────────────┘
771    fderiv 𝕜 (λy, c • f y) x = c • fderiv 𝕜 f x :=
id     └────┘               └────┘   
src    └────┘                      └────┘
typ    └────┘               └────┘   
doc    └────┘                         └────┘
772  (h.has_fderiv_at.const_smul c).fderiv
id    └────────────┘└─────────┘  └────┘
src    └────────────┘└─────────┘   └────┘
typ   └────────────┘└─────────┘  └────┘
773  
774  end const_smul
775  
776  section add
777  /-! ### Derivative of the sum of two functions -/
778  
779  theorem has_fderiv_at_filter.add
780    (hf : has_fderiv_at_filter f f' x L) (hg : has_fderiv_at_filter g g' x L) :
id           └──────────────────┘  └┘          └──────────────────┘  └┘  
src          └──────────────────┘                 └──────────────────┘
typ          └──────────────────┘  └┘          └──────────────────┘  └┘  
doc          └──────────────────┘                 └──────────────────┘
781    has_fderiv_at_filter (λ y, f y + g y) (f' + g') x L :=
id     └──────────────────┘             └┘  └┘   
src    └──────────────────┘                     
typ    └──────────────────┘             └┘  └┘   
doc    └──────────────────┘
782  (hf.add hg).congr_left $ λ _, by simp
id    └┘└──┘ └┘ └────────┘      
src     └──┘    └────────┘            └────
typ   └┘└──┘ └┘ └────────┘           └────
doc                                   └────
txt                                   └────
par                                   └────
pid                                       
st                                   └─────
783  
src  
typ  
doc  
txt  
par  
pid  
st   
784  theorem has_fderiv_within_at.add
785    (hf : has_fderiv_within_at f f' s x) (hg : has_fderiv_within_at g g' s x) :
id           └──────────────────┘  └┘          └──────────────────┘  └┘  
src          └──────────────────┘                 └──────────────────┘
typ          └──────────────────┘  └┘          └──────────────────┘  └┘  
doc          └──────────────────┘                 └──────────────────┘
786    has_fderiv_within_at (λ y, f y + g y) (f' + g') s x :=
id     └──────────────────┘             └┘  └┘   
src    └──────────────────┘                     
typ    └──────────────────┘             └┘  └┘   
doc    └──────────────────┘
787  hf.add hg
id   └┘└──┘ └┘
src    └──┘
typ  └┘└──┘ └┘
788  
789  theorem has_fderiv_at.add
790    (hf : has_fderiv_at f f' x) (hg : has_fderiv_at g g' x) :
id           └───────────┘  └┘         └───────────┘  └┘ 
src          └───────────┘               └───────────┘
typ          └───────────┘  └┘         └───────────┘  └┘ 
doc          └───────────┘               └───────────┘
791    has_fderiv_at (λ x, f x + g x) (f' + g') x :=
id     └───────────┘             └┘  └┘  
src    └───────────┘                     
typ    └───────────┘             └┘  └┘  
doc    └───────────┘
792  hf.add hg
id   └┘└──┘ └┘
src    └──┘
typ  └┘└──┘ └┘
793  
794  lemma differentiable_within_at.add
795    (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) :
id           └──────────────────────┘            └──────────────────────┘    
src          └──────────────────────┘                └──────────────────────┘
typ          └──────────────────────┘            └──────────────────────┘    
doc          └──────────────────────┘                └──────────────────────┘
796    differentiable_within_at 𝕜 (λ y, f y + g y) s x :=
id     └──────────────────────┘              
src    └──────────────────────┘             
typ    └──────────────────────┘              
doc    └──────────────────────┘
797  (hf.has_fderiv_within_at.add hg.has_fderiv_within_at).differentiable_within_at
id    └┘└───────────────────┘└──┘ └┘└───────────────────┘ └──────────────────────┘
src     └───────────────────┘└──┘   └───────────────────┘ └──────────────────────┘
typ   └┘└───────────────────┘└──┘ └┘└───────────────────┘ └──────────────────────┘
798  
799  lemma differentiable_at.add
800    (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
801    differentiable_at 𝕜 (λ y, f y + g y) x :=
id     └───────────────┘             
src    └───────────────┘             
typ    └───────────────┘             
doc    └───────────────┘
802  (hf.has_fderiv_at.add hg.has_fderiv_at).differentiable_at
id    └┘└────────────┘└──┘ └┘└────────────┘ └───────────────┘
src     └────────────┘└──┘   └────────────┘ └───────────────┘
typ   └┘└────────────┘└──┘ └┘└────────────┘ └───────────────┘
803  
804  lemma differentiable_on.add
805    (hf : differentiable_on 𝕜 f s) (hg : differentiable_on 𝕜 g s) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
806    differentiable_on 𝕜 (λy, f y + g y) s :=
id     └───────────────┘            
src    └───────────────┘            
typ    └───────────────┘            
doc    └───────────────┘
807  λx hx, (hf x hx).add (hg x hx)
id     └┘   └┘  └┘ └─┘   └┘  └┘
src                  └─┘
typ    └┘   └┘  └┘ └─┘   └┘  └┘
808  
809  lemma differentiable.add
810    (hf : differentiable 𝕜 f) (hg : differentiable 𝕜 g) :
id           └────────────┘          └────────────┘  
src          └────────────┘            └────────────┘
typ          └────────────┘          └────────────┘  
doc          └────────────┘            └────────────┘
811    differentiable 𝕜 (λy, f y + g y) :=
id     └────────────┘          
src    └────────────┘            
typ    └────────────┘          
doc    └────────────┘
812  λx, (hf x).add (hg x)
id       └┘  └─┘   └┘ 
src            └─┘
typ      └┘  └─┘   └┘ 
813  
814  lemma fderiv_within_add (hxs : unique_diff_within_at 𝕜 s x)
id                                  └───────────────────┘   
src                                 └───────────────────┘
typ                                 └───────────────────┘   
doc                                 └───────────────────┘
815    (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) :
id           └──────────────────────┘            └──────────────────────┘    
src          └──────────────────────┘                └──────────────────────┘
typ          └──────────────────────┘            └──────────────────────┘    
doc          └──────────────────────┘                └──────────────────────┘
816    fderiv_within 𝕜 (λy, f y + g y) s x = fderiv_within 𝕜 f s x + fderiv_within 𝕜 g s x :=
id     └───────────┘               └───────────┘      └───────────┘    
src    └───────────┘                       └───────────┘          └───────────┘
typ    └───────────┘               └───────────┘      └───────────┘    
doc    └───────────┘                         └───────────┘           └───────────┘
817  (hf.has_fderiv_within_at.add hg.has_fderiv_within_at).fderiv_within hxs
id    └┘└───────────────────┘└──┘ └┘└───────────────────┘ └───────────┘  └─┘
src     └───────────────────┘└──┘   └───────────────────┘ └───────────┘
typ   └┘└───────────────────┘└──┘ └┘└───────────────────┘ └───────────┘  └─┘
818  
819  lemma fderiv_add
820    (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
821    fderiv 𝕜 (λy, f y + g y) x = fderiv 𝕜 f x + fderiv 𝕜 g x :=
id     └────┘              └────┘     └────┘   
src    └────┘                     └────┘        └────┘
typ    └────┘              └────┘     └────┘   
doc    └────┘                       └────┘         └────┘
822  (hf.has_fderiv_at.add hg.has_fderiv_at).fderiv
id    └┘└────────────┘└──┘ └┘└────────────┘ └────┘
src     └────────────┘└──┘   └────────────┘ └────┘
typ   └┘└────────────┘└──┘ └┘└────────────┘ └────┘
823  
824  theorem has_fderiv_at_filter.add_const
825    (hf : has_fderiv_at_filter f f' x L) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
826    has_fderiv_at_filter (λ y, f y + c) f' x L :=
id     └──────────────────┘           └┘  
src    └──────────────────┘           
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
827  add_zero f' ▸ hf.add (has_fderiv_at_filter_const _ _ _)
id   └──────┘ └┘  └┘└──┘  └────────────────────────┘
src  └──────┘       └──┘  └────────────────────────┘
typ  └──────┘ └┘  └┘└──┘  └────────────────────────┘
828  
829  theorem has_fderiv_within_at.add_const
830    (hf : has_fderiv_within_at f f' s x) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
831    has_fderiv_within_at (λ y, f y + c) f' s x :=
id     └──────────────────┘           └┘  
src    └──────────────────┘           
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
832  hf.add_const c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
833  
834  theorem has_fderiv_at.add_const
835    (hf : has_fderiv_at f f' x) (c : F):
id           └───────────┘  └┘        
src          └───────────┘
typ          └───────────┘  └┘        
doc          └───────────┘
836    has_fderiv_at (λ x, f x + c) f' x :=
id     └───────────┘           └┘ 
src    └───────────┘           
typ    └───────────┘           └┘ 
doc    └───────────┘
837  hf.add_const c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
838  
839  lemma differentiable_within_at.add_const
840    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
841    differentiable_within_at 𝕜 (λ y, f y + c) s x :=
id     └──────────────────────┘             
src    └──────────────────────┘             
typ    └──────────────────────┘             
doc    └──────────────────────┘
842  (hf.has_fderiv_within_at.add_const c).differentiable_within_at
id    └┘└───────────────────┘└────────┘  └──────────────────────┘
src     └───────────────────┘└────────┘   └──────────────────────┘
typ   └┘└───────────────────┘└────────┘  └──────────────────────┘
843  
844  lemma differentiable_at.add_const
845    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
846    differentiable_at 𝕜 (λ y, f y + c) x :=
id     └───────────────┘            
src    └───────────────┘             
typ    └───────────────┘            
doc    └───────────────┘
847  (hf.has_fderiv_at.add_const c).differentiable_at
id    └┘└────────────┘└────────┘  └───────────────┘
src     └────────────┘└────────┘   └───────────────┘
typ   └┘└────────────┘└────────┘  └───────────────┘
848  
849  lemma differentiable_on.add_const
850    (hf : differentiable_on 𝕜 f s) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
851    differentiable_on 𝕜 (λy, f y + c) s :=
id     └───────────────┘           
src    └───────────────┘            
typ    └───────────────┘           
doc    └───────────────┘
852  λx hx, (hf x hx).add_const c
id     └┘   └┘  └┘ └───────┘  
src                  └───────┘
typ    └┘   └┘  └┘ └───────┘  
853  
854  lemma differentiable.add_const
855    (hf : differentiable 𝕜 f) (c : F) :
id           └────────────┘         
src          └────────────┘
typ          └────────────┘         
doc          └────────────┘
856    differentiable 𝕜 (λy, f y + c) :=
id     └────────────┘         
src    └────────────┘            
typ    └────────────┘         
doc    └────────────┘
857  λx, (hf x).add_const c
id       └┘  └───────┘  
src            └───────┘
typ      └┘  └───────┘  
858  
859  lemma fderiv_within_add_const (hxs : unique_diff_within_at 𝕜 s x)
id                                        └───────────────────┘   
src                                       └───────────────────┘
typ                                       └───────────────────┘   
doc                                       └───────────────────┘
860    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
861    fderiv_within 𝕜 (λy, f y + c) s x = fderiv_within 𝕜 f s x :=
id     └───────────┘              └───────────┘    
src    └───────────┘                     └───────────┘
typ    └───────────┘              └───────────┘    
doc    └───────────┘                       └───────────┘
862  (hf.has_fderiv_within_at.add_const c).fderiv_within hxs
id    └┘└───────────────────┘└────────┘  └───────────┘  └─┘
src     └───────────────────┘└────────┘   └───────────┘
typ   └┘└───────────────────┘└────────┘  └───────────┘  └─┘
863  
864  lemma fderiv_add_const
865    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
866    fderiv 𝕜 (λy, f y + c) x = fderiv 𝕜 f x :=
id     └────┘             └────┘   
src    └────┘                   └────┘
typ    └────┘             └────┘   
doc    └────┘                     └────┘
867  (hf.has_fderiv_at.add_const c).fderiv
id    └┘└────────────┘└────────┘  └────┘
src     └────────────┘└────────┘   └────┘
typ   └┘└────────────┘└────────┘  └────┘
868  
869  theorem has_fderiv_at_filter.const_add
870    (hf : has_fderiv_at_filter f f' x L) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
871    has_fderiv_at_filter (λ y, c + f y) f' x L :=
id     └──────────────────┘           └┘  
src    └──────────────────┘         
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
872  zero_add f' ▸ (has_fderiv_at_filter_const _ _ _).add hf
id   └──────┘ └┘   └────────────────────────┘       └─┘  └┘
src  └──────┘      └────────────────────────┘       └─┘
typ  └──────┘ └┘   └────────────────────────┘       └─┘  └┘
873  
874  theorem has_fderiv_within_at.const_add
875    (hf : has_fderiv_within_at f f' s x) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
876    has_fderiv_within_at (λ y, c + f y) f' s x :=
id     └──────────────────┘           └┘  
src    └──────────────────┘         
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
877  hf.const_add c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
878  
879  theorem has_fderiv_at.const_add
880    (hf : has_fderiv_at f f' x) (c : F):
id           └───────────┘  └┘        
src          └───────────┘
typ          └───────────┘  └┘        
doc          └───────────┘
881    has_fderiv_at (λ x, c + f x) f' x :=
id     └───────────┘           └┘ 
src    └───────────┘         
typ    └───────────┘           └┘ 
doc    └───────────┘
882  hf.const_add c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
883  
884  lemma differentiable_within_at.const_add
885    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
886    differentiable_within_at 𝕜 (λ y, c + f y) s x :=
id     └──────────────────────┘             
src    └──────────────────────┘           
typ    └──────────────────────┘             
doc    └──────────────────────┘
887  (hf.has_fderiv_within_at.const_add c).differentiable_within_at
id    └┘└───────────────────┘└────────┘  └──────────────────────┘
src     └───────────────────┘└────────┘   └──────────────────────┘
typ   └┘└───────────────────┘└────────┘  └──────────────────────┘
888  
889  lemma differentiable_at.const_add
890    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
891    differentiable_at 𝕜 (λ y, c + f y) x :=
id     └───────────────┘            
src    └───────────────┘           
typ    └───────────────┘            
doc    └───────────────┘
892  (hf.has_fderiv_at.const_add c).differentiable_at
id    └┘└────────────┘└────────┘  └───────────────┘
src     └────────────┘└────────┘   └───────────────┘
typ   └┘└────────────┘└────────┘  └───────────────┘
893  
894  lemma differentiable_on.const_add
895    (hf : differentiable_on 𝕜 f s) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
896    differentiable_on 𝕜 (λy, c + f y) s :=
id     └───────────────┘           
src    └───────────────┘          
typ    └───────────────┘           
doc    └───────────────┘
897  λx hx, (hf x hx).const_add c
id     └┘   └┘  └┘ └───────┘  
src                  └───────┘
typ    └┘   └┘  └┘ └───────┘  
898  
899  lemma differentiable.const_add
900    (hf : differentiable 𝕜 f) (c : F) :
id           └────────────┘         
src          └────────────┘
typ          └────────────┘         
doc          └────────────┘
901    differentiable 𝕜 (λy, c + f y) :=
id     └────────────┘         
src    └────────────┘          
typ    └────────────┘         
doc    └────────────┘
902  λx, (hf x).const_add c
id       └┘  └───────┘  
src            └───────┘
typ      └┘  └───────┘  
903  
904  lemma fderiv_within_const_add (hxs : unique_diff_within_at 𝕜 s x)
id                                        └───────────────────┘   
src                                       └───────────────────┘
typ                                       └───────────────────┘   
doc                                       └───────────────────┘
905    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
906    fderiv_within 𝕜 (λy, c + f y) s x = fderiv_within 𝕜 f s x :=
id     └───────────┘              └───────────┘    
src    └───────────┘                     └───────────┘
typ    └───────────┘              └───────────┘    
doc    └───────────┘                       └───────────┘
907  (hf.has_fderiv_within_at.const_add c).fderiv_within hxs
id    └┘└───────────────────┘└────────┘  └───────────┘  └─┘
src     └───────────────────┘└────────┘   └───────────┘
typ   └┘└───────────────────┘└────────┘  └───────────┘  └─┘
908  
909  lemma fderiv_const_add
910    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
911    fderiv 𝕜 (λy, c + f y) x = fderiv 𝕜 f x :=
id     └────┘             └────┘   
src    └────┘                   └────┘
typ    └────┘             └────┘   
doc    └────┘                     └────┘
912  (hf.has_fderiv_at.const_add c).fderiv
id    └┘└────────────┘└────────┘  └────┘
src     └────────────┘└────────┘   └────┘
typ   └┘└────────────┘└────────┘  └────┘
913  
914  end add
915  
916  section neg
917  /-! ### Derivative of the negative of a function -/
918  
919  theorem has_fderiv_at_filter.neg (h : has_fderiv_at_filter f f' x L) :
id                                         └──────────────────┘  └┘  
src                                        └──────────────────┘
typ                                        └──────────────────┘  └┘  
doc                                        └──────────────────┘
920    has_fderiv_at_filter (λ x, -f x) (-f') x L :=
id     └──────────────────┘          └┘   
src    └──────────────────┘             
typ    └──────────────────┘          └┘   
doc    └──────────────────┘
921  (h.const_smul (-1:𝕜)).congr (by simp) (by simp)
id    └─────────┘      └───┘
src    └─────────┘       └───┘      └──┘      └──┘
typ   └─────────┘      └───┘      └──┘      └──┘
doc                                  └──┘      └──┘
txt                                  └──┘      └──┘
par                                  └──┘      └──┘
st                                  └───┘     └───┘
922  
923  theorem has_fderiv_within_at.neg (h : has_fderiv_within_at f f' s x) :
id                                         └──────────────────┘  └┘  
src                                        └──────────────────┘
typ                                        └──────────────────┘  └┘  
doc                                        └──────────────────┘
924    has_fderiv_within_at (λ x, -f x) (-f') s x :=
id     └──────────────────┘          └┘   
src    └──────────────────┘             
typ    └──────────────────┘          └┘   
doc    └──────────────────┘
925  h.neg
id   └──┘
src   └──┘
typ  └──┘
926  
927  theorem has_fderiv_at.neg (h : has_fderiv_at f f' x) :
id                                  └───────────┘  └┘ 
src                                 └───────────┘
typ                                 └───────────┘  └┘ 
doc                                 └───────────┘
928    has_fderiv_at (λ x, -f x) (-f') x :=
id     └───────────┘          └┘  
src    └───────────┘             
typ    └───────────┘          └┘  
doc    └───────────┘
929  h.neg
id   └──┘
src   └──┘
typ  └──┘
930  
931  lemma differentiable_within_at.neg (h : differentiable_within_at 𝕜 f s x) :
id                                           └──────────────────────┘    
src                                          └──────────────────────┘
typ                                          └──────────────────────┘    
doc                                          └──────────────────────┘
932    differentiable_within_at 𝕜 (λy, -f y) s x :=
id     └──────────────────────┘          
src    └──────────────────────┘        
typ    └──────────────────────┘          
doc    └──────────────────────┘
933  h.has_fderiv_within_at.neg.differentiable_within_at
id   └───────────────────┘└──┘└───────────────────────┘
src   └───────────────────┘└──┘└───────────────────────┘
typ  └───────────────────┘└──┘└───────────────────────┘
934  
935  lemma differentiable_at.neg (h : differentiable_at 𝕜 f x) :
id                                    └───────────────┘   
src                                   └───────────────┘
typ                                   └───────────────┘   
doc                                   └───────────────┘
936    differentiable_at 𝕜 (λy, -f y) x :=
id     └───────────────┘         
src    └───────────────┘        
typ    └───────────────┘         
doc    └───────────────┘
937  h.has_fderiv_at.neg.differentiable_at
id   └────────────┘└──┘└────────────────┘
src   └────────────┘└──┘└────────────────┘
typ  └────────────┘└──┘└────────────────┘
938  
939  lemma differentiable_on.neg (h : differentiable_on 𝕜 f s) :
id                                    └───────────────┘   
src                                   └───────────────┘
typ                                   └───────────────┘   
doc                                   └───────────────┘
940    differentiable_on 𝕜 (λy, -f y) s :=
id     └───────────────┘         
src    └───────────────┘        
typ    └───────────────┘         
doc    └───────────────┘
941  λx hx, (h x hx).neg
id     └┘     └┘ └─┘
src                 └─┘
typ    └┘     └┘ └─┘
942  
943  lemma differentiable.neg (h : differentiable 𝕜 f) :
id                                 └────────────┘  
src                                └────────────┘
typ                                └────────────┘  
doc                                └────────────┘
944    differentiable 𝕜 (λy, -f y) :=
id     └────────────┘       
src    └────────────┘        
typ    └────────────┘       
doc    └────────────┘
945  λx, (h x).neg
id         └─┘
src           └─┘
typ        └─┘
946  
947  lemma fderiv_within_neg (hxs : unique_diff_within_at 𝕜 s x)
id                                  └───────────────────┘   
src                                 └───────────────────┘
typ                                 └───────────────────┘   
doc                                 └───────────────────┘
948    (h : differentiable_within_at 𝕜 f s x) :
id          └──────────────────────┘    
src         └──────────────────────┘
typ         └──────────────────────┘    
doc         └──────────────────────┘
949    fderiv_within 𝕜 (λy, -f y) s x = - fderiv_within 𝕜 f s x :=
id     └───────────┘             └───────────┘    
src    └───────────┘                   └───────────┘
typ    └───────────┘             └───────────┘    
doc    └───────────┘                      └───────────┘
950  h.has_fderiv_within_at.neg.fderiv_within hxs
id   └───────────────────┘└──┘└────────────┘ └─┘
src   └───────────────────┘└──┘└────────────┘
typ  └───────────────────┘└──┘└────────────┘ └─┘
951  
952  lemma fderiv_neg (h : differentiable_at 𝕜 f x) :
id                         └───────────────┘   
src                        └───────────────┘
typ                        └───────────────┘   
doc                        └───────────────┘
953    fderiv 𝕜 (λy, -f y) x = - fderiv 𝕜 f x :=
id     └────┘            └────┘   
src    └────┘                 └────┘
typ    └────┘            └────┘   
doc    └────┘                    └────┘
954  h.has_fderiv_at.neg.fderiv
id   └────────────┘└──┘└─────┘
src   └────────────┘└──┘└─────┘
typ  └────────────┘└──┘└─────┘
955  
956  end neg
957  
958  section sub
959  /-! ### Derivative of the difference of two functions -/
960  
961  theorem has_fderiv_at_filter.sub
962    (hf : has_fderiv_at_filter f f' x L) (hg : has_fderiv_at_filter g g' x L) :
id           └──────────────────┘  └┘          └──────────────────┘  └┘  
src          └──────────────────┘                 └──────────────────┘
typ          └──────────────────┘  └┘          └──────────────────┘  └┘  
doc          └──────────────────┘                 └──────────────────┘
963    has_fderiv_at_filter (λ x, f x - g x) (f' - g') x L :=
id     └──────────────────┘             └┘  └┘   
src    └──────────────────┘                     
typ    └──────────────────┘             └┘  └┘   
doc    └──────────────────┘
964  hf.add hg.neg
id   └┘└──┘ └┘└──┘
src    └──┘   └──┘
typ  └┘└──┘ └┘└──┘
965  
966  theorem has_fderiv_within_at.sub
967    (hf : has_fderiv_within_at f f' s x) (hg : has_fderiv_within_at g g' s x) :
id           └──────────────────┘  └┘          └──────────────────┘  └┘  
src          └──────────────────┘                 └──────────────────┘
typ          └──────────────────┘  └┘          └──────────────────┘  └┘  
doc          └──────────────────┘                 └──────────────────┘
968    has_fderiv_within_at (λ x, f x - g x) (f' - g') s x :=
id     └──────────────────┘             └┘  └┘   
src    └──────────────────┘                     
typ    └──────────────────┘             └┘  └┘   
doc    └──────────────────┘
969  hf.sub hg
id   └┘└──┘ └┘
src    └──┘
typ  └┘└──┘ └┘
970  
971  theorem has_fderiv_at.sub
972    (hf : has_fderiv_at f f' x) (hg : has_fderiv_at g g' x) :
id           └───────────┘  └┘         └───────────┘  └┘ 
src          └───────────┘               └───────────┘
typ          └───────────┘  └┘         └───────────┘  └┘ 
doc          └───────────┘               └───────────┘
973    has_fderiv_at (λ x, f x - g x) (f' - g') x :=
id     └───────────┘             └┘  └┘  
src    └───────────┘                     
typ    └───────────┘             └┘  └┘  
doc    └───────────┘
974  hf.sub hg
id   └┘└──┘ └┘
src    └──┘
typ  └┘└──┘ └┘
975  
976  lemma differentiable_within_at.sub
977    (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) :
id           └──────────────────────┘            └──────────────────────┘    
src          └──────────────────────┘                └──────────────────────┘
typ          └──────────────────────┘            └──────────────────────┘    
doc          └──────────────────────┘                └──────────────────────┘
978    differentiable_within_at 𝕜 (λ y, f y - g y) s x :=
id     └──────────────────────┘              
src    └──────────────────────┘             
typ    └──────────────────────┘              
doc    └──────────────────────┘
979  (hf.has_fderiv_within_at.sub hg.has_fderiv_within_at).differentiable_within_at
id    └┘└───────────────────┘└──┘ └┘└───────────────────┘ └──────────────────────┘
src     └───────────────────┘└──┘   └───────────────────┘ └──────────────────────┘
typ   └┘└───────────────────┘└──┘ └┘└───────────────────┘ └──────────────────────┘
980  
981  lemma differentiable_at.sub
982    (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
983    differentiable_at 𝕜 (λ y, f y - g y) x :=
id     └───────────────┘             
src    └───────────────┘             
typ    └───────────────┘             
doc    └───────────────┘
984  (hf.has_fderiv_at.sub hg.has_fderiv_at).differentiable_at
id    └┘└────────────┘└──┘ └┘└────────────┘ └───────────────┘
src     └────────────┘└──┘   └────────────┘ └───────────────┘
typ   └┘└────────────┘└──┘ └┘└────────────┘ └───────────────┘
985  
986  lemma differentiable_on.sub
987    (hf : differentiable_on 𝕜 f s) (hg : differentiable_on 𝕜 g s) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
988    differentiable_on 𝕜 (λy, f y - g y) s :=
id     └───────────────┘            
src    └───────────────┘            
typ    └───────────────┘            
doc    └───────────────┘
989  λx hx, (hf x hx).sub (hg x hx)
id     └┘   └┘  └┘ └─┘   └┘  └┘
src                  └─┘
typ    └┘   └┘  └┘ └─┘   └┘  └┘
990  
991  lemma differentiable.sub
992    (hf : differentiable 𝕜 f) (hg : differentiable 𝕜 g) :
id           └────────────┘          └────────────┘  
src          └────────────┘            └────────────┘
typ          └────────────┘          └────────────┘  
doc          └────────────┘            └────────────┘
993    differentiable 𝕜 (λy, f y - g y) :=
id     └────────────┘          
src    └────────────┘            
typ    └────────────┘          
doc    └────────────┘
994  λx, (hf x).sub (hg x)
id       └┘  └─┘   └┘ 
src            └─┘
typ      └┘  └─┘   └┘ 
995  
996  lemma fderiv_within_sub (hxs : unique_diff_within_at 𝕜 s x)
id                                  └───────────────────┘   
src                                 └───────────────────┘
typ                                 └───────────────────┘   
doc                                 └───────────────────┘
997    (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) :
id           └──────────────────────┘            └──────────────────────┘    
src          └──────────────────────┘                └──────────────────────┘
typ          └──────────────────────┘            └──────────────────────┘    
doc          └──────────────────────┘                └──────────────────────┘
998    fderiv_within 𝕜 (λy, f y - g y) s x = fderiv_within 𝕜 f s x - fderiv_within 𝕜 g s x :=
id     └───────────┘               └───────────┘      └───────────┘    
src    └───────────┘                       └───────────┘          └───────────┘
typ    └───────────┘               └───────────┘      └───────────┘    
doc    └───────────┘                         └───────────┘           └───────────┘
999  (hf.has_fderiv_within_at.sub hg.has_fderiv_within_at).fderiv_within hxs
id    └┘└───────────────────┘└──┘ └┘└───────────────────┘ └───────────┘  └─┘
src     └───────────────────┘└──┘   └───────────────────┘ └───────────┘
typ   └┘└───────────────────┘└──┘ └┘└───────────────────┘ └───────────┘  └─┘
1000  
1001  lemma fderiv_sub
1002    (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) :
id           └───────────────┘           └───────────────┘   
src          └───────────────┘              └───────────────┘
typ          └───────────────┘           └───────────────┘   
doc          └───────────────┘              └───────────────┘
1003    fderiv 𝕜 (λy, f y - g y) x = fderiv 𝕜 f x - fderiv 𝕜 g x :=
id     └────┘              └────┘     └────┘   
src    └────┘                     └────┘        └────┘
typ    └────┘              └────┘     └────┘   
doc    └────┘                       └────┘         └────┘
1004  (hf.has_fderiv_at.sub hg.has_fderiv_at).fderiv
id    └┘└────────────┘└──┘ └┘└────────────┘ └────┘
src     └────────────┘└──┘   └────────────┘ └────┘
typ   └┘└────────────┘└──┘ └┘└────────────┘ └────┘
1005  
1006  theorem has_fderiv_at_filter.is_O_sub (h : has_fderiv_at_filter f f' x L) :
id                                              └──────────────────┘  └┘  
src                                             └──────────────────┘
typ                                             └──────────────────┘  └┘  
doc                                             └──────────────────┘
1007  is_O (λ x', f x' - f x) (λ x', x' - x) L :=
id   └──┘    └┘   └┘        └┘  └┘    
src  └──┘                             
typ  └──┘    └┘   └┘        └┘  └┘    
doc  └──┘
1008  h.is_O.congr_of_sub.2 (f'.is_O_sub _ _)
id   └───┘└───────────┘   └┘└───────┘
src   └───┘└───────────┘     └───────┘
typ  └───┘└───────────┘   └┘└───────┘
1009  
1010  theorem has_fderiv_at_filter.sub_const
1011    (hf : has_fderiv_at_filter f f' x L) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
1012    has_fderiv_at_filter (λ x, f x - c) f' x L :=
id     └──────────────────┘           └┘  
src    └──────────────────┘           
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
1013  hf.add_const (-c)
id   └┘└────────┘  
src    └────────┘  
typ  └┘└────────┘  
1014  
1015  theorem has_fderiv_within_at.sub_const
1016    (hf : has_fderiv_within_at f f' s x) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
1017    has_fderiv_within_at (λ x, f x - c) f' s x :=
id     └──────────────────┘           └┘  
src    └──────────────────┘           
typ    └──────────────────┘           └┘  
doc    └──────────────────┘
1018  hf.sub_const c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
1019  
1020  theorem has_fderiv_at.sub_const
1021    (hf : has_fderiv_at f f' x) (c : F) :
id           └───────────┘  └┘        
src          └───────────┘
typ          └───────────┘  └┘        
doc          └───────────┘
1022    has_fderiv_at (λ x, f x - c) f' x :=
id     └───────────┘           └┘ 
src    └───────────┘           
typ    └───────────┘           └┘ 
doc    └───────────┘
1023  hf.sub_const c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
1024  
1025  lemma differentiable_within_at.sub_const
1026    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
1027    differentiable_within_at 𝕜 (λ y, f y - c) s x :=
id     └──────────────────────┘             
src    └──────────────────────┘             
typ    └──────────────────────┘             
doc    └──────────────────────┘
1028  (hf.has_fderiv_within_at.sub_const c).differentiable_within_at
id    └┘└───────────────────┘└────────┘  └──────────────────────┘
src     └───────────────────┘└────────┘   └──────────────────────┘
typ   └┘└───────────────────┘└────────┘  └──────────────────────┘
1029  
1030  lemma differentiable_at.sub_const
1031    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1032    differentiable_at 𝕜 (λ y, f y - c) x :=
id     └───────────────┘            
src    └───────────────┘             
typ    └───────────────┘            
doc    └───────────────┘
1033  (hf.has_fderiv_at.sub_const c).differentiable_at
id    └┘└────────────┘└────────┘  └───────────────┘
src     └────────────┘└────────┘   └───────────────┘
typ   └┘└────────────┘└────────┘  └───────────────┘
1034  
1035  lemma differentiable_on.sub_const
1036    (hf : differentiable_on 𝕜 f s) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1037    differentiable_on 𝕜 (λy, f y - c) s :=
id     └───────────────┘           
src    └───────────────┘            
typ    └───────────────┘           
doc    └───────────────┘
1038  λx hx, (hf x hx).sub_const c
id     └┘   └┘  └┘ └───────┘  
src                  └───────┘
typ    └┘   └┘  └┘ └───────┘  
1039  
1040  lemma differentiable.sub_const
1041    (hf : differentiable 𝕜 f) (c : F) :
id           └────────────┘         
src          └────────────┘
typ          └────────────┘         
doc          └────────────┘
1042    differentiable 𝕜 (λy, f y - c) :=
id     └────────────┘         
src    └────────────┘            
typ    └────────────┘         
doc    └────────────┘
1043  λx, (hf x).sub_const c
id       └┘  └───────┘  
src            └───────┘
typ      └┘  └───────┘  
1044  
1045  lemma fderiv_within_sub_const (hxs : unique_diff_within_at 𝕜 s x)
id                                        └───────────────────┘   
src                                       └───────────────────┘
typ                                       └───────────────────┘   
doc                                       └───────────────────┘
1046    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
1047    fderiv_within 𝕜 (λy, f y - c) s x = fderiv_within 𝕜 f s x :=
id     └───────────┘              └───────────┘    
src    └───────────┘                     └───────────┘
typ    └───────────┘              └───────────┘    
doc    └───────────┘                       └───────────┘
1048  (hf.has_fderiv_within_at.sub_const c).fderiv_within hxs
id    └┘└───────────────────┘└────────┘  └───────────┘  └─┘
src     └───────────────────┘└────────┘   └───────────┘
typ   └┘└───────────────────┘└────────┘  └───────────┘  └─┘
1049  
1050  lemma fderiv_sub_const
1051    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1052    fderiv 𝕜 (λy, f y - c) x = fderiv 𝕜 f x :=
id     └────┘             └────┘   
src    └────┘                   └────┘
typ    └────┘             └────┘   
doc    └────┘                     └────┘
1053  (hf.has_fderiv_at.sub_const c).fderiv
id    └┘└────────────┘└────────┘  └────┘
src     └────────────┘└────────┘   └────┘
typ   └┘└────────────┘└────────┘  └────┘
1054  
1055  theorem has_fderiv_at_filter.const_sub
1056    (hf : has_fderiv_at_filter f f' x L) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
1057    has_fderiv_at_filter (λ x, c - f x) (-f') x L :=
id     └──────────────────┘            └┘   
src    └──────────────────┘                
typ    └──────────────────┘            └┘   
doc    └──────────────────┘
1058  hf.neg.const_add c
id   └┘└──┘└────────┘ 
src    └──┘└────────┘
typ  └┘└──┘└────────┘ 
1059  
1060  theorem has_fderiv_within_at.const_sub
1061    (hf : has_fderiv_within_at f f' s x) (c : F) :
id           └──────────────────┘  └┘         
src          └──────────────────┘
typ          └──────────────────┘  └┘         
doc          └──────────────────┘
1062    has_fderiv_within_at (λ x, c - f x) (-f') s x :=
id     └──────────────────┘            └┘   
src    └──────────────────┘                
typ    └──────────────────┘            └┘   
doc    └──────────────────┘
1063  hf.const_sub c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
1064  
1065  theorem has_fderiv_at.const_sub
1066    (hf : has_fderiv_at f f' x) (c : F) :
id           └───────────┘  └┘        
src          └───────────┘
typ          └───────────┘  └┘        
doc          └───────────┘
1067    has_fderiv_at (λ x, c - f x) (-f') x :=
id     └───────────┘            └┘  
src    └───────────┘                
typ    └───────────┘            └┘  
doc    └───────────┘
1068  hf.const_sub c
id   └┘└────────┘ 
src    └────────┘
typ  └┘└────────┘ 
1069  
1070  lemma differentiable_within_at.const_sub
1071    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
1072    differentiable_within_at 𝕜 (λ y, c - f y) s x :=
id     └──────────────────────┘             
src    └──────────────────────┘           
typ    └──────────────────────┘             
doc    └──────────────────────┘
1073  (hf.has_fderiv_within_at.const_sub c).differentiable_within_at
id    └┘└───────────────────┘└────────┘  └──────────────────────┘
src     └───────────────────┘└────────┘   └──────────────────────┘
typ   └┘└───────────────────┘└────────┘  └──────────────────────┘
1074  
1075  lemma differentiable_at.const_sub
1076    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1077    differentiable_at 𝕜 (λ y, c - f y) x :=
id     └───────────────┘            
src    └───────────────┘           
typ    └───────────────┘            
doc    └───────────────┘
1078  (hf.has_fderiv_at.const_sub c).differentiable_at
id    └┘└────────────┘└────────┘  └───────────────┘
src     └────────────┘└────────┘   └───────────────┘
typ   └┘└────────────┘└────────┘  └───────────────┘
1079  
1080  lemma differentiable_on.const_sub
1081    (hf : differentiable_on 𝕜 f s) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1082    differentiable_on 𝕜 (λy, c - f y) s :=
id     └───────────────┘           
src    └───────────────┘          
typ    └───────────────┘           
doc    └───────────────┘
1083  λx hx, (hf x hx).const_sub c
id     └┘   └┘  └┘ └───────┘  
src                  └───────┘
typ    └┘   └┘  └┘ └───────┘  
1084  
1085  lemma differentiable.const_sub
1086    (hf : differentiable 𝕜 f) (c : F) :
id           └────────────┘         
src          └────────────┘
typ          └────────────┘         
doc          └────────────┘
1087    differentiable 𝕜 (λy, c - f y) :=
id     └────────────┘         
src    └────────────┘          
typ    └────────────┘         
doc    └────────────┘
1088  λx, (hf x).const_sub c
id       └┘  └───────┘  
src            └───────┘
typ      └┘  └───────┘  
1089  
1090  lemma fderiv_within_const_sub (hxs : unique_diff_within_at 𝕜 s x)
id                                        └───────────────────┘   
src                                       └───────────────────┘
typ                                       └───────────────────┘   
doc                                       └───────────────────┘
1091    (hf : differentiable_within_at 𝕜 f s x) (c : F) :
id           └──────────────────────┘           
src          └──────────────────────┘
typ          └──────────────────────┘           
doc          └──────────────────────┘
1092    fderiv_within 𝕜 (λy, c - f y) s x = -fderiv_within 𝕜 f s x :=
id     └───────────┘              └───────────┘    
src    └───────────┘                     └───────────┘
typ    └───────────┘              └───────────┘    
doc    └───────────┘                        └───────────┘
1093  (hf.has_fderiv_within_at.const_sub c).fderiv_within hxs
id    └┘└───────────────────┘└────────┘  └───────────┘  └─┘
src     └───────────────────┘└────────┘   └───────────┘
typ   └┘└───────────────────┘└────────┘  └───────────┘  └─┘
1094  
1095  lemma fderiv_const_sub
1096    (hf : differentiable_at 𝕜 f x) (c : F) :
id           └───────────────┘          
src          └───────────────┘
typ          └───────────────┘          
doc          └───────────────┘
1097    fderiv 𝕜 (λy, c - f y) x = -fderiv 𝕜 f x :=
id     └────┘             └────┘   
src    └────┘                   └────┘
typ    └────┘             └────┘   
doc    └────┘                      └────┘
1098  (hf.has_fderiv_at.const_sub c).fderiv
id    └┘└────────────┘└────────┘  └────┘
src     └────────────┘└────────┘   └────┘
typ   └┘└────────────┘└────────┘  └────┘
1099  
1100  end sub
1101  
1102  section continuous
1103  /-! ### Deducing continuity from differentiability -/
1104  
1105  theorem has_fderiv_at_filter.tendsto_nhds
1106    (hL : L ≤ 𝓝 x) (h : has_fderiv_at_filter f f' x L) :
id                     └──────────────────┘  └┘  
src                      └──────────────────┘
typ                    └──────────────────┘  └┘  
doc                       └──────────────────┘
1107    tendsto f L (𝓝 (f x)) :=
id     └─────┘       
src    └─────┘      
typ    └─────┘       
doc    └─────┘      
1108  begin
st   └─────
1109    have : tendsto (λ x', f x' - f x) L (𝓝 0),
id            └─────┘                   
src    └─────┘└─────┘  └───┘     └┘  └─┘
typ    └─────┘└─────┘  └───┘   └┘ └─┘
doc    └─────┘└─────┘  └───┘      └┘  └─┘
txt    └─────┘         └───┘      └┘   └─┘
par    └─────┘         └───┘      └┘   └─┘
pid    └───┘└┘         └───┘      └┘   └─┘
st   ──────────────────────────────────────────┘└─
1110    { refine h.is_O_sub.trans_tendsto (tendsto_le_left hL _),
id              └──────────────────────┘  └─────────────┘ └┘
src      └─────┘└──────────────────────┘ └─────────────┘  └─┘
typ      └─────┘└──────────────────────┘ └─────────────┘└┘└─┘
doc      └─────┘                                          └─┘
txt      └─────┘                                          └─┘
par      └─────┘                                          └─┘
pid                                                      └─┘
st   ───┘└────────────────────────────────────────────────────┘└─
1111      rw ← sub_self x, exact tendsto_id.sub tendsto_const_nhds },
id            └──────┘         └────────────┘ └────────────────┘
src      └───┘└──────┘   └────┘└────────────┘└────────────────┘
typ      └───┘└──────┘  └────┘└────────────┘└────────────────┘
doc      └───┘           └────┘                                
txt      └───┘           └────┘                                
par      └───┘           └────┘                                
pid        └─┘                                                
st   ──────────────────┘└────────────────────────────────────────┘└┘
1112    have := tendsto.add this tendsto_const_nhds,
id             └─────────┘ └──┘ └────────────────┘
src    └──────┘└─────────┘    └────────────────┘
typ    └──────┘└─────────┘└──┘└────────────────┘
doc    └──────┘               
txt    └──────┘               
par    └──────┘               
pid    └───┘└─┘               
st   ────────────────────────────────────────────┘└─
1113    rw zero_add (f x) at this,
id        └──────┘   
src    └─┘└──────┘   └───────┘
typ    └─┘└──────┘ └───────┘
doc    └─┘           └───────┘
txt    └─┘           └───────┘
par    └─┘           └───────┘
pid                 └──────┘
st   ──────────────────────────┘└─
1114    exact this.congr (by simp)
id           └────────┘
src    └────┘└────────┘   └──┘└┘
typ    └────┘└────────┘   └──┘└┘
doc    └────┘             └──┘└┘
txt    └────┘             └──┘└┘
par    └────┘             └──┘└┘
pid                      └────┘
st   ─────────────────────┘└───┘└┘
1115  end
st   └─┘
1116  
1117  theorem has_fderiv_within_at.continuous_within_at
1118    (h : has_fderiv_within_at f f' s x) : continuous_within_at f s x :=
id          └──────────────────┘  └┘      └──────────────────┘   
src         └──────────────────┘             └──────────────────┘
typ         └──────────────────┘  └┘      └──────────────────┘   
doc         └──────────────────┘             └──────────────────┘
1119  has_fderiv_at_filter.tendsto_nhds lattice.inf_le_left h
id   └───────────────────────────────┘ └─────────────────┘ 
src  └───────────────────────────────┘ └─────────────────┘
typ  └───────────────────────────────┘ └─────────────────┘ 
1120  
1121  theorem has_fderiv_at.continuous_at (h : has_fderiv_at f f' x) :
id                                            └───────────┘  └┘ 
src                                           └───────────┘
typ                                           └───────────┘  └┘ 
doc                                           └───────────┘
1122    continuous_at f x :=
id     └───────────┘  
src    └───────────┘
typ    └───────────┘  
doc    └───────────┘
1123  has_fderiv_at_filter.tendsto_nhds (le_refl _) h
id   └───────────────────────────────┘  └─────┘    
src  └───────────────────────────────┘  └─────┘
typ  └───────────────────────────────┘  └─────┘    
1124  
1125  lemma differentiable_within_at.continuous_within_at (h : differentiable_within_at 𝕜 f s x) :
id                                                            └──────────────────────┘    
src                                                           └──────────────────────┘
typ                                                           └──────────────────────┘    
doc                                                           └──────────────────────┘
1126    continuous_within_at f s x :=
id     └──────────────────┘   
src    └──────────────────┘
typ    └──────────────────┘   
doc    └──────────────────┘
1127  let ⟨f', hf'⟩ := h in hf'.continuous_within_at
id   └─┘      └─┘            └───────────────────┘
src                           └───────────────────┘
typ  └─┘      └─┘            └───────────────────┘
1128  
1129  lemma differentiable_at.continuous_at (h : differentiable_at 𝕜 f x) : continuous_at f x :=
id                                              └───────────────┘       └───────────┘  
src                                             └───────────────┘          └───────────┘
typ                                             └───────────────┘       └───────────┘  
doc                                             └───────────────┘          └───────────┘
1130  let ⟨f', hf'⟩ := h in hf'.continuous_at
id   └─┘      └─┘            └────────────┘
src                           └────────────┘
typ  └─┘      └─┘            └────────────┘
1131  
1132  lemma differentiable_on.continuous_on (h : differentiable_on 𝕜 f s) : continuous_on f s :=
id                                              └───────────────┘       └───────────┘  
src                                             └───────────────┘          └───────────┘
typ                                             └───────────────┘       └───────────┘  
doc                                             └───────────────┘          └───────────┘
1133  λx hx, (h x hx).continuous_within_at
id     └┘     └┘ └──────────────────┘
src                 └──────────────────┘
typ    └┘     └┘ └──────────────────┘
1134  
1135  lemma differentiable.continuous (h : differentiable 𝕜 f) : continuous f :=
id                                        └────────────┘      └────────┘ 
src                                       └────────────┘        └────────┘
typ                                       └────────────┘      └────────┘ 
doc                                       └────────────┘        └────────┘
1136  continuous_iff_continuous_at.2 $ λx, (h x).continuous_at
id   └──────────────────────────┘          └───────────┘
src  └──────────────────────────┘             └───────────┘
typ  └──────────────────────────┘          └───────────┘
1137  
1138  end continuous
1139  
1140  section bilinear_map
1141  /-! ### Derivative of a bounded bilinear map -/
1142  
1143  variables {b : E × F → G} {u : set (E × F) }
id                                 └─┘    
src                                └─┘    
typ                                └─┘    
1144  
1145  open normed_field
1146  
1147  lemma is_bounded_bilinear_map.has_fderiv_at (h : is_bounded_bilinear_map 𝕜 b) (p : E × F) :
id                                                    └─────────────────────┘           
src                                                   └─────────────────────┘             
typ                                                   └─────────────────────┘           
doc                                                   └─────────────────────┘
1148    has_fderiv_at b (h.deriv p) p :=
id     └───────────┘   └────┘   
src    └───────────┘     └────┘
typ    └───────────┘   └────┘   
doc    └───────────┘     └────┘
1149  begin
st   └─────
1150    have : (λ (x : E × F), b x - b p - (h.deriv p) (x - p)) = (λx, b (x.1 - p.1, x.2 - p.2)),
id                                     └─────┘                                     
src    └─────┘  └────┘  └─┘      └─────┘ └┘    └─┘  └─┘  └─┘  └──┘ └─┘  └──┘
typ    └─────┘  └────┘└─┘      └─────┘ └┘    └─┘  └─┘ └─┘  └──┘ └─┘ └──┘
doc    └─────┘  └────┘   └─┘       └─────┘ └┘    └─┘   └─┘   └─┘  └──┘ └─┘  └──┘
txt    └─────┘  └────┘   └─┘               └┘    └─┘   └─┘   └─┘  └──┘ └─┘  └──┘
par    └─────┘  └────┘   └─┘               └┘    └─┘   └─┘   └─┘  └──┘ └─┘  └──┘
pid    └───┘└┘  └────┘   └─┘               └┘    └─┘   └─┘   └─┘  └──┘ └─┘  └──┘
st   ─────────────────────────────────────────────────────────────────────────────────────────┘└─
1151    { ext x,
src      └───┘
typ      └───┘
doc      └───┘
txt      └───┘
par      └───┘
pid         └┘
st   ───┘└───┘└─
1152      delta is_bounded_bilinear_map.deriv,
src      └─────────────────────────────────┘
typ      └─────────────────────────────────┘
doc      └─────────────────────────────────┘
txt      └─────────────────────────────────┘
par      └─────────────────────────────────┘
pid           └────────────────────────────┘
st   ──────────────────────────────────────┘└─
1153      change b x - b p - (b (p.1, x.2-p.2) + b (x.1-p.1, p.2))
id                                            
src      └─────┘          └──┘ └┘  └──┘   └┘  └──┘ └────
typ      └─────┘          └──┘ └┘  └──┘   └┘  └──┘ └────
doc      └─────┘          └──┘ └┘  └──┘    └┘  └──┘ └────
txt      └─────┘          └──┘ └┘  └──┘    └┘  └──┘ └────
par      └─────┘          └──┘ └┘  └──┘    └┘  └──┘ └────
pid                      └──┘ └┘  └──┘    └┘  └──┘ └────
st   ─────────────────────────────────────────────────────────────
1154             = b (x.1 - p.1, x.2 - p.2),
id                                 
src  ──────────┘   └─┘  └──┘ └─┘  └─┘
typ  ──────────┘  └─┘  └──┘└─┘ └─┘
doc  ──────────┘    └─┘  └──┘ └─┘  └─┘
txt  ──────────┘    └─┘  └──┘ └─┘  └─┘
par  ──────────┘    └─┘  └──┘ └─┘  └─┘
pid  ──────────┘    └─┘  └──┘ └─┘  └─┘
st   ────────────────────────────────────┘└─
1155      have : b x = b (x.1, x.2), by { cases x, refl },
id                                          
src      └─────┘     └──┘ └─┘       └────┘   └───┘
typ      └─────┘    └──┘└─┘       └────┘  └───┘
doc      └─────┘      └──┘ └─┘       └────┘   └───┘
txt      └─────┘      └──┘ └─┘       └────┘   └───┘
par      └─────┘      └──┘ └─┘       └────┘   └───┘
pid      └───┘└┘      └──┘ └─┘                   
st   ────────────────────────────┘     └──────┘└─────┘└┘
1156      rw this,
id          └──┘
src      └─┘
typ      └─┘└──┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ──────────┘└─
1157      have : b p = b (p.1, p.2), by { cases p, refl },
id                                          
src      └─────┘     └──┘ └─┘       └────┘   └───┘
typ      └─────┘    └──┘└─┘       └────┘  └───┘
doc      └─────┘      └──┘ └─┘       └────┘   └───┘
txt      └─────┘      └──┘ └─┘       └────┘   └───┘
par      └─────┘      └──┘ └─┘       └────┘   └───┘
pid      └───┘└┘      └──┘ └─┘                   
st   ────────────────────────────┘     └──────┘└─────┘└┘
1158      rw this,
id          └──┘
src      └─┘
typ      └─┘└──┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ──────────┘└─
1159      simp only [h.map_sub_left, h.map_sub_right],
src      └─────────┘              └┘               
typ      └─────────┘└────────────┘└┘└─────────────┘
doc      └─────────┘              └┘               
txt      └─────────┘              └┘               
par      └─────────┘              └┘               
pid          └──┘└┘              └┘               
st   ──────────────────────────────────────────────┘└─
1160      abel },
src      └───┘
typ      └───┘
doc      └───┘
txt      └───┘
par      └───┘
pid          
st   ────────┘└┘
1161    rw [has_fderiv_at, has_fderiv_at_filter, this],
id         └───────────┘  └──────────────────┘  └──┘
src    └──┘└───────────┘└┘└──────────────────┘└┘    
typ    └──┘└───────────┘└┘└──────────────────┘└┘└──┘
doc    └──┘└───────────┘└┘└──────────────────┘└┘    
txt    └──┘             └┘                    └┘    
par    └──┘             └┘                    └┘    
pid      └┘             └┘                    └┘    
st   ──────────────────┘└────────────────────┘└────┘└──
1162    rcases h.bound with ⟨C, Cpos, hC⟩,
id            └─────┘
src    └─────┘└─────┘└─────────────────┘
typ    └─────┘└─────┘└─────────────────┘
doc    └─────┘       └─────────────────┘
txt    └─────┘       └─────────────────┘
par    └─────┘       └─────────────────┘
pid                 └─────────────────┘
st   ──────────────────────────────────┘└─
1163    have A : asymptotics.is_O (λx : E × F, b (x.1 - p.1, x.2 - p.2))
id              └──────────────┘             
src    └───────┘└──────────────┘  └──┘   └┘  └─┘  └──┘ └─┘  └────
typ    └───────┘└──────────────┘  └──┘ └┘ └─┘  └──┘ └─┘  └────
doc    └───────┘└──────────────┘  └──┘   └┘   └─┘  └──┘ └─┘  └────
txt    └───────┘                  └──┘   └┘   └─┘  └──┘ └─┘  └────
par    └───────┘                  └──┘   └┘   └─┘  └──┘ └─┘  └────
pid    └────┘└─┘                  └──┘   └┘   └─┘  └──┘ └─┘  └────
st   ───────────────────────────────────────────────────────────────────
1164      (λx, ∥x - p∥ * ∥x - p∥) (𝓝 p) :=
id                              
src  ───┘  └─┘        └┘  └────
typ  ───┘  └─┘        └┘ └────
doc  ───┘  └─┘           └┘  └────
txt  ───┘  └─┘           └┘   └────
par  ───┘  └─┘           └┘   └────
pid  ───┘  └─┘           └┘   └───
st   ─────────────────────────────────────
1165    ⟨C, filter.univ_mem_sets' (λx, begin
id        └───────────────────┘
src  ─┘  └┘└───────────────────┘  └─┘     
typ  ─┘ └┘└───────────────────┘  └─┘     
doc  ─┘  └┘                       └─┘     
txt  ─┘  └┘                       └─┘     
par  ─┘  └┘                       └─┘     
pid  ─┘  └┘                       └─┘     
st   ────────────────────────────────┘└─────
1166      simp only [mem_set_of_eq, norm_mul, norm_norm],
id                  └───────────┘  └──────┘  └───────┘
src  ───┘└─────────┘└───────────┘└┘└──────┘└┘└───────┘└─
typ  ───┘└─────────┘└───────────┘└┘└──────┘└┘└───────┘└─
doc  ───┘└─────────┘             └┘        └┘         └─
txt  ───┘└─────────┘             └┘        └┘         └─
par  ───┘└─────────┘             └┘        └┘         └─
pid  ──────────────┘             └┘        └┘         └──
st   ─────────────────────────────────────────────────┘└─
1167      calc ∥b (x.1 - p.1, x.2 - p.2)∥ ≤ C * ∥x.1 - p.1∥ * ∥x.2 - p.2∥ : hC _ _
id                                                                     └┘
src  ───┘        └─┘  └──┘ └─┘  └─┘      └─┘  └┘    └─┘  └┘ └─┘  └────
typ  ───┘       └─┘  └──┘ └─┘  └─┘     └─┘  └┘   └─┘ └┘ └─┘└┘└────
doc  ───┘        └─┘  └──┘ └─┘  └─┘      └─┘  └┘    └─┘  └┘ └─┘  └────
txt  ───┘        └─┘  └──┘ └─┘  └─┘      └─┘  └┘    └─┘  └┘ └─┘  └────
par  ───┘        └─┘  └──┘ └─┘  └─┘      └─┘  └┘    └─┘  └┘ └─┘  └────
pid  ───┘        └─┘  └──┘ └─┘  └─┘      └─┘  └┘    └─┘  └┘ └─┘  └────
st   ─────────────────────────────────────────────────────────────────────────────
1168      ... ≤ C * ∥x-p∥ * ∥x-p∥ : by apply_rules [mul_le_mul, le_max_left, le_max_right, norm_nonneg,
id                                                 └────────┘  └─────────┘  └──────────┘  └─────────┘
src  ───────┘              └─┘  └───────────┘└────────┘└┘└─────────┘└┘└──────────┘└┘└─────────┘└─
typ  ───────┘              └─┘  └───────────┘└────────┘└┘└─────────┘└┘└──────────┘└┘└─────────┘└─
doc  ───────┘              └─┘  └───────────┘          └┘           └┘            └┘           └─
txt  ───────┘              └─┘  └───────────┘          └┘           └┘            └┘           └─
par  ───────┘              └─┘  └───────────┘          └┘           └┘            └┘           └─
pid  ───────┘              └─┘  └────────────┘          └┘           └┘            └┘           └─
st   ───────────────────────────────┘└─────────────────────────────────────────────────────────────────
1169        le_of_lt Cpos, le_refl, mul_nonneg, norm_nonneg, norm_nonneg]
id         └──────┘ └──┘  └─────┘  └────────┘  └─────────┘  └─────────┘
src  ─────┘└──────┘    └┘└─────┘└┘└────────┘└┘└─────────┘└┘└─────────┘└─
typ  ─────┘└──────┘└──┘└┘└─────┘└┘└────────┘└┘└─────────┘└┘└─────────┘└─
doc  ─────┘            └┘       └┘          └┘           └┘           └─
txt  ─────┘            └┘       └┘          └┘           └┘           └─
par  ─────┘            └┘       └┘          └┘           └┘           └─
pid  ─────┘            └┘       └┘          └┘           └┘           └─
st   ────────────────────────────────────────────────────────────────────
1170      ... = C * (∥x-p∥ * ∥x-p∥) : mul_assoc _ _ _ end)⟩,
id                                   └───────┘
src  ───┘└──┘               └──┘└───────┘└──────────┘
typ  ───┘└──┘               └──┘└───────┘└──────────┘
doc  ───┘└──┘               └──┘         └──────────┘
txt  ───┘└──┘               └──┘         └──────────┘
par  ───┘└──┘               └──┘         └──────────┘
pid  ───────┘               └──┘         └──────────┘
st   ───┘└─────────────────────────────────────────┘└──┘└┘└─
1171    have B : asymptotics.is_o (λ (x : E × F), ∥x - p∥ * ∥x - p∥)
id              └──────────────┘            
src    └───────┘└──────────────┘  └────┘   └─┘           └─
typ    └───────┘└──────────────┘  └────┘ └─┘           └─
doc    └───────┘└──────────────┘  └────┘   └─┘           └─
txt    └───────┘                  └────┘   └─┘           └─
par    └───────┘                  └────┘   └─┘           └─
pid    └────┘└─┘                  └────┘   └─┘           └─
st   ───────────────────────────────────────────────────────────────
1172      (λx, 1 * ∥x - p∥) (𝓝 p),
id                            
src  ───┘  └───┘      └┘   
typ  ───┘  └───┘      └┘  
doc  ───┘  └───┘      └┘   
txt  ───┘  └───┘      └┘   
par  ───┘  └───┘      └┘   
pid  ───┘  └───┘      └┘   
st   ──────────────────────────┘└─
1173    { refine asymptotics.is_o.mul_is_O (asymptotics.is_o.norm_left _) (asymptotics.is_O_refl _ _),
id              └───────────────────────┘  └────────────────────────┘     └───────────────────┘
src      └─────┘└───────────────────────┘ └────────────────────────┘└──┘ └───────────────────┘└───┘
typ      └─────┘└───────────────────────┘ └────────────────────────┘└──┘ └───────────────────┘└───┘
doc      └─────┘                          └────────────────────────┘└──┘                      └───┘
txt      └─────┘                                                    └──┘                      └───┘
par      └─────┘                                                    └──┘                      └───┘
pid                                                                └──┘                      └───┘
st   ───┘└─────────────────────────────────────────────────────────────────────────────────────────┘└─
1174      apply (asymptotics.is_o_one_iff ℝ).2,
id              └──────────────────────┘
src      └────┘ └──────────────────────┘ └─┘
typ      └────┘ └──────────────────────┘ └─┘
doc      └────┘                          └─┘
txt      └────┘                          └─┘
par      └────┘                          └─┘
pid                                     └┘
st   ───────────────────────────────────────┘└─
1175      rw [← sub_self p],
id             └──────┘ 
src      └────┘└──────┘ 
typ      └────┘└──────┘
doc      └────┘         
txt      └────┘         
par      └────┘         
pid        └──┘         
st   ───────────────────┘└──
1176      exact tendsto_id.sub tendsto_const_nhds },
id             └────────────┘ └────────────────┘
src      └────┘└────────────┘└────────────────┘
typ      └────┘└────────────┘└────────────────┘
doc      └────┘                                
txt      └────┘                                
par      └────┘                                
pid                                           
st   ───────────────────────────────────────────┘└┘
1177    simp only [one_mul, asymptotics.is_o_norm_right] at B,
id                └─────┘  └─────────────────────────┘
src    └─────────┘└─────┘└┘└─────────────────────────┘└────┘
typ    └─────────┘└─────┘└┘└─────────────────────────┘└────┘
doc    └─────────┘       └┘                           └────┘
txt    └─────────┘       └┘                           └────┘
par    └─────────┘       └┘                           └────┘
pid        └──┘└┘       └┘                           └──┘
st   ──────────────────────────────────────────────────────┘└─
1178    exact A.trans_is_o B
id           └──────────┘ 
src    └────┘└──────────┘ 
typ    └────┘└──────────┘
doc    └────┘             
txt    └────┘             
par    └────┘             
pid                      
st   ──────────────────────┘
1179  end
st   └─┘
1180  
1181  lemma is_bounded_bilinear_map.has_fderiv_within_at (h : is_bounded_bilinear_map 𝕜 b) (p : E × F) :
id                                                           └─────────────────────┘           
src                                                          └─────────────────────┘             
typ                                                          └─────────────────────┘           
doc                                                          └─────────────────────┘
1182    has_fderiv_within_at b (h.deriv p) u p :=
id     └──────────────────┘   └────┘    
src    └──────────────────┘     └────┘
typ    └──────────────────┘   └────┘    
doc    └──────────────────┘     └────┘
1183  (h.has_fderiv_at p).has_fderiv_within_at
id    └────────────┘  └──────────────────┘
src    └────────────┘   └──────────────────┘
typ   └────────────┘  └──────────────────┘
1184  
1185  lemma is_bounded_bilinear_map.differentiable_at (h : is_bounded_bilinear_map 𝕜 b) (p : E × F) :
id                                                        └─────────────────────┘           
src                                                       └─────────────────────┘             
typ                                                       └─────────────────────┘           
doc                                                       └─────────────────────┘
1186    differentiable_at 𝕜 b p :=
id     └───────────────┘   
src    └───────────────┘
typ    └───────────────┘   
doc    └───────────────┘
1187  (h.has_fderiv_at p).differentiable_at
id    └────────────┘  └───────────────┘
src    └────────────┘   └───────────────┘
typ   └────────────┘  └───────────────┘
1188  
1189  lemma is_bounded_bilinear_map.differentiable_within_at (h : is_bounded_bilinear_map 𝕜 b) (p : E × F) :
id                                                               └─────────────────────┘           
src                                                              └─────────────────────┘             
typ                                                              └─────────────────────┘           
doc                                                              └─────────────────────┘
1190    differentiable_within_at 𝕜 b u p :=
id     └──────────────────────┘    
src    └──────────────────────┘
typ    └──────────────────────┘    
doc    └──────────────────────┘
1191  (h.differentiable_at p).differentiable_within_at
id    └────────────────┘  └──────────────────────┘
src    └────────────────┘   └──────────────────────┘
typ   └────────────────┘  └──────────────────────┘
1192  
1193  lemma is_bounded_bilinear_map.fderiv (h : is_bounded_bilinear_map 𝕜 b) (p : E × F) :
id                                             └─────────────────────┘           
src                                            └─────────────────────┘             
typ                                            └─────────────────────┘           
doc                                            └─────────────────────┘
1194    fderiv 𝕜 b p = h.deriv p :=
id     └────┘     └────┘ 
src    └────┘         └────┘
typ    └────┘     └────┘ 
doc    └────┘          └────┘
1195  has_fderiv_at.fderiv (h.has_fderiv_at p)
id   └──────────────────┘  └────────────┘ 
src  └──────────────────┘   └────────────┘
typ  └──────────────────┘  └────────────┘ 
1196  
1197  lemma is_bounded_bilinear_map.fderiv_within (h : is_bounded_bilinear_map 𝕜 b) (p : E × F)
id                                                    └─────────────────────┘           
src                                                   └─────────────────────┘             
typ                                                   └─────────────────────┘           
doc                                                   └─────────────────────┘
1198    (hxs : unique_diff_within_at 𝕜 u p) : fderiv_within 𝕜 b u p = h.deriv p :=
id            └───────────────────┘       └───────────┘      └────┘ 
src           └───────────────────┘          └───────────┘           └────┘
typ           └───────────────────┘       └───────────┘      └────┘ 
doc           └───────────────────┘          └───────────┘            └────┘
1199  begin
st   └─────
1200    rw differentiable_at.fderiv_within (h.differentiable_at p) hxs,
id        └─────────────────────────────┘  └─────────────────┘   └─┘
src    └─┘└─────────────────────────────┘ └─────────────────┘ └┘
typ    └─┘└─────────────────────────────┘ └─────────────────┘└┘└─┘
doc    └─┘                                                    └┘
txt    └─┘                                                    └┘
par    └─┘                                                    └┘
pid                                                          └┘
st   ───────────────────────────────────────────────────────────────┘└─
1201    exact h.fderiv p
id           └──────┘ 
src    └────┘└──────┘ 
typ    └────┘└──────┘
doc    └────┘         
txt    └────┘         
par    └────┘         
pid                  
st   ──────────────────┘
1202  end
st   └─┘
1203  
1204  lemma is_bounded_bilinear_map.differentiable (h : is_bounded_bilinear_map 𝕜 b) :
id                                                     └─────────────────────┘  
src                                                    └─────────────────────┘
typ                                                    └─────────────────────┘  
doc                                                    └─────────────────────┘
1205    differentiable 𝕜 b :=
id     └────────────┘  
src    └────────────┘
typ    └────────────┘  
doc    └────────────┘
1206  λx, h.differentiable_at x
id      └────────────────┘ 
src       └────────────────┘
typ     └────────────────┘ 
1207  
1208  lemma is_bounded_bilinear_map.differentiable_on (h : is_bounded_bilinear_map 𝕜 b) :
id                                                        └─────────────────────┘  
src                                                       └─────────────────────┘
typ                                                       └─────────────────────┘  
doc                                                       └─────────────────────┘
1209    differentiable_on 𝕜 b u :=
id     └───────────────┘   
src    └───────────────┘
typ    └───────────────┘   
doc    └───────────────┘
1210  h.differentiable.differentiable_on
id   └─────────────┘└────────────────┘
src   └─────────────┘└────────────────┘
typ  └─────────────┘└────────────────┘
1211  
1212  lemma is_bounded_bilinear_map.continuous (h : is_bounded_bilinear_map 𝕜 b) :
id                                                 └─────────────────────┘  
src                                                └─────────────────────┘
typ                                                └─────────────────────┘  
doc                                                └─────────────────────┘
1213    continuous b :=
id     └────────┘ 
src    └────────┘
typ    └────────┘ 
doc    └────────┘
1214  h.differentiable.continuous
id   └─────────────┘└─────────┘
src   └─────────────┘└─────────┘
typ  └─────────────┘└─────────┘
1215  
1216  lemma is_bounded_bilinear_map.continuous_left (h : is_bounded_bilinear_map 𝕜 b) {f : F} :
id                                                      └─────────────────────┘         
src                                                     └─────────────────────┘
typ                                                     └─────────────────────┘         
doc                                                     └─────────────────────┘
1217    continuous (λe, b (e, f)) :=
id     └────────┘        
src    └────────┘        
typ    └────────┘        
doc    └────────┘
1218  h.continuous.comp (continuous_id.prod_mk continuous_const)
id   └─────────┘└───┘  └───────────┘└──────┘ └──────────────┘
src   └─────────┘└───┘  └───────────┘└──────┘ └──────────────┘
typ  └─────────┘└───┘  └───────────┘└──────┘ └──────────────┘
1219  
1220  lemma is_bounded_bilinear_map.continuous_right (h : is_bounded_bilinear_map 𝕜 b) {e : E} :
id                                                       └─────────────────────┘         
src                                                      └─────────────────────┘
typ                                                      └─────────────────────┘         
doc                                                      └─────────────────────┘
1221    continuous (λf, b (e, f)) :=
id     └────────┘        
src    └────────┘        
typ    └────────┘        
doc    └────────┘
1222  h.continuous.comp (continuous_const.prod_mk continuous_id)
id   └─────────┘└───┘  └──────────────┘└──────┘ └───────────┘
src   └─────────┘└───┘  └──────────────┘└──────┘ └───────────┘
typ  └─────────┘└───┘  └──────────────┘└──────┘ └───────────┘
1223  
1224  end bilinear_map
1225  
1226  section cartesian_product
1227  /-! ### Derivative of the cartesian product of two functions -/
1228  
1229  variables {f₂ : E → G} {f₂' : E →L[𝕜] G}
id                                   └─┘ 
src                                  └─┘ 
typ                                  └─┘ 
doc                                  └─┘ 
1230  
1231  lemma has_fderiv_at_filter.prod
1232    (hf₁ : has_fderiv_at_filter f₁ f₁' x L) (hf₂ : has_fderiv_at_filter f₂ f₂' x L) :
id            └──────────────────┘ └┘ └─┘           └──────────────────┘ └┘ └─┘  
src           └──────────────────┘                    └──────────────────┘
typ           └──────────────────┘ └┘ └─┘           └──────────────────┘ └┘ └─┘  
doc           └──────────────────┘                    └──────────────────┘
1233    has_fderiv_at_filter (λx, (f₁ x, f₂ x)) (continuous_linear_map.prod f₁' f₂') x L :=
id     └──────────────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘   
src    └──────────────────┘                    └────────────────────────┘
typ    └──────────────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘   
doc    └──────────────────┘                     └────────────────────────┘
1234  begin
st   └─────
1235    have : (λ (x' : E), (f₁ x', f₂ x') - (f₁ x, f₂ x) - (continuous_linear_map.prod f₁' f₂') (x' -x)) =
id                                                         └────────────────────────┘                   
src    └─────┘  └─────┘ └─┘     └┘    └┘    └┘   └┘  └────────────────────────┘      └┘     └─┘
typ    └─────┘  └─────┘ └─┘     └┘    └┘    └┘   └┘  └────────────────────────┘      └┘     └─┘
doc    └─────┘  └─────┘ └─┘     └┘    └┘     └┘   └┘  └────────────────────────┘      └┘     └─┘ 
txt    └─────┘  └─────┘ └─┘     └┘    └┘     └┘   └┘                                  └┘     └─┘ 
par    └─────┘  └─────┘ └─┘     └┘    └┘     └┘   └┘                                  └┘     └─┘ 
pid    └───┘└┘  └─────┘ └─┘     └┘    └┘     └┘   └┘                                  └┘     └─┘ 
st   ──────────────────────────────────────────────────────────────────────────────────────────────────────
1236             (λ (x' : E), (f₁ x' - f₁ x - f₁' (x' - x), f₂ x' - f₂ x - f₂' (x' - x))) := rfl,
id                                  └┘     └─┘                   └┘     └─┘              └─┘
src  ──────────┘  └─────┘ └─┘                 └─┘                 └─────┘└─┘
typ  ──────────┘  └─────┘└─┘     └┘  └─┘     └─┘     └┘  └─┘    └─────┘└─┘
doc  ──────────┘  └─────┘ └─┘                  └─┘                 └─────┘
txt  ──────────┘  └─────┘ └─┘                  └─┘                 └─────┘
par  ──────────┘  └─────┘ └─┘                  └─┘                 └─────┘
pid  ──────────┘  └─────┘ └─┘                  └─┘                 └─┘└──┘
st   ─────────────────────────────────────────────────────────────────────────────────────────┘└─
1237    rw [has_fderiv_at_filter, this],
id         └──────────────────┘  └──┘
src    └──┘└──────────────────┘└┘    
typ    └──┘└──────────────────┘└┘└──┘
doc    └──┘└──────────────────┘└┘    
txt    └──┘                    └┘    
par    └──┘                    └┘    
pid      └┘                    └┘    
st   ─────────────────────────┘└────┘└──
1238    rw [asymptotics.is_o_prod_left],
id         └────────────────────────┘
src    └──┘└────────────────────────┘
typ    └──┘└────────────────────────┘
doc    └──┘                          
txt    └──┘                          
par    └──┘                          
pid      └┘                          
st   ───────────────────────────────┘└──
1239    exact ⟨hf₁, hf₂⟩
id            └─┘  └─┘
src    └────┘    └┘   └┘
typ    └────┘ └─┘└┘└─┘└┘
doc    └────┘    └┘   └┘
txt    └────┘    └┘   └┘
par    └────┘    └┘   └┘
pid             └┘   
st   ──────────────────┘
1240  end
st   └─┘
1241  
1242  lemma has_fderiv_within_at.prod
1243    (hf₁ : has_fderiv_within_at f₁ f₁' s x) (hf₂ : has_fderiv_within_at f₂ f₂' s x) :
id            └──────────────────┘ └┘ └─┘           └──────────────────┘ └┘ └─┘  
src           └──────────────────┘                    └──────────────────┘
typ           └──────────────────┘ └┘ └─┘           └──────────────────┘ └┘ └─┘  
doc           └──────────────────┘                    └──────────────────┘
1244    has_fderiv_within_at (λx, (f₁ x, f₂ x)) (continuous_linear_map.prod f₁' f₂') s x :=
id     └──────────────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘   
src    └──────────────────┘                    └────────────────────────┘
typ    └──────────────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘   
doc    └──────────────────┘                     └────────────────────────┘
1245  hf₁.prod hf₂
id   └─┘└───┘ └─┘
src     └───┘
typ  └─┘└───┘ └─┘
1246  
1247  lemma has_fderiv_at.prod (hf₁ : has_fderiv_at f₁ f₁' x) (hf₂ : has_fderiv_at f₂ f₂' x) :
id                                   └───────────┘ └┘ └─┘          └───────────┘ └┘ └─┘ 
src                                  └───────────┘                  └───────────┘
typ                                  └───────────┘ └┘ └─┘          └───────────┘ └┘ └─┘ 
doc                                  └───────────┘                  └───────────┘
1248    has_fderiv_at (λx, (f₁ x, f₂ x)) (continuous_linear_map.prod f₁' f₂') x :=
id     └───────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘  
src    └───────────┘                    └────────────────────────┘
typ    └───────────┘     └┘   └┘     └────────────────────────┘ └─┘ └─┘  
doc    └───────────┘                     └────────────────────────┘
1249  hf₁.prod hf₂
id   └─┘└───┘ └─┘
src     └───┘
typ  └─┘└───┘ └─┘
1250  
1251  lemma differentiable_within_at.prod
1252    (hf₁ : differentiable_within_at 𝕜 f₁ s x) (hf₂ : differentiable_within_at 𝕜 f₂ s x) :
id            └──────────────────────┘  └┘           └──────────────────────┘  └┘  
src           └──────────────────────┘                  └──────────────────────┘
typ           └──────────────────────┘  └┘           └──────────────────────┘  └┘  
doc           └──────────────────────┘                  └──────────────────────┘
1253    differentiable_within_at 𝕜 (λx:E, (f₁ x, f₂ x)) s x :=
id     └──────────────────────┘        └┘   └┘     
src    └──────────────────────┘          
typ    └──────────────────────┘        └┘   └┘     
doc    └──────────────────────┘
1254  (hf₁.has_fderiv_within_at.prod hf₂.has_fderiv_within_at).differentiable_within_at
id    └─┘└───────────────────┘└───┘ └─┘└───────────────────┘ └──────────────────────┘
src      └───────────────────┘└───┘    └───────────────────┘ └──────────────────────┘
typ   └─┘└───────────────────┘└───┘ └─┘└───────────────────┘ └──────────────────────┘
1255  
1256  lemma differentiable_at.prod (hf₁ : differentiable_at 𝕜 f₁ x) (hf₂ : differentiable_at 𝕜 f₂ x) :
id                                       └───────────────┘  └┘          └───────────────┘  └┘ 
src                                      └───────────────┘                └───────────────┘
typ                                      └───────────────┘  └┘          └───────────────┘  └┘ 
doc                                      └───────────────┘                └───────────────┘
1257    differentiable_at 𝕜 (λx:E, (f₁ x, f₂ x)) x :=
id     └───────────────┘        └┘   └┘    
src    └───────────────┘          
typ    └───────────────┘        └┘   └┘    
doc    └───────────────┘
1258  (hf₁.has_fderiv_at.prod hf₂.has_fderiv_at).differentiable_at
id    └─┘└────────────┘└───┘ └─┘└────────────┘ └───────────────┘
src      └────────────┘└───┘    └────────────┘ └───────────────┘
typ   └─┘└────────────┘└───┘ └─┘└────────────┘ └───────────────┘
1259  
1260  lemma differentiable_on.prod (hf₁ : differentiable_on 𝕜 f₁ s) (hf₂ : differentiable_on 𝕜 f₂ s) :
id                                       └───────────────┘  └┘          └───────────────┘  └┘ 
src                                      └───────────────┘                └───────────────┘
typ                                      └───────────────┘  └┘          └───────────────┘  └┘ 
doc                                      └───────────────┘                └───────────────┘
1261    differentiable_on 𝕜 (λx:E, (f₁ x, f₂ x)) s :=
id     └───────────────┘        └┘   └┘    
src    └───────────────┘          
typ    └───────────────┘        └┘   └┘    
doc    └───────────────┘
1262  λx hx, differentiable_within_at.prod (hf₁ x hx) (hf₂ x hx)
id     └┘  └───────────────────────────┘  └─┘  └┘   └─┘  └┘
src         └───────────────────────────┘
typ    └┘  └───────────────────────────┘  └─┘  └┘   └─┘  └┘
1263  
1264  lemma differentiable.prod (hf₁ : differentiable 𝕜 f₁) (hf₂ : differentiable 𝕜 f₂) :
id                                    └────────────┘  └┘         └────────────┘  └┘
src                                   └────────────┘              └────────────┘
typ                                   └────────────┘  └┘         └────────────┘  └┘
doc                                   └────────────┘              └────────────┘
1265    differentiable 𝕜 (λx:E, (f₁ x, f₂ x)) :=
id     └────────────┘        └┘   └┘ 
src    └────────────┘          
typ    └────────────┘        └┘   └┘ 
doc    └────────────┘
1266  λ x, differentiable_at.prod (hf₁ x) (hf₂ x)
id       └────────────────────┘  └─┘    └─┘ 
src       └────────────────────┘
typ      └────────────────────┘  └─┘    └─┘ 
1267  
1268  lemma differentiable_at.fderiv_prod
1269    (hf₁ : differentiable_at 𝕜 f₁ x) (hf₂ : differentiable_at 𝕜 f₂ x) :
id            └───────────────┘  └┘          └───────────────┘  └┘ 
src           └───────────────┘                └───────────────┘
typ           └───────────────┘  └┘          └───────────────┘  └┘ 
doc           └───────────────┘                └───────────────┘
1270    fderiv 𝕜 (λx:E, (f₁ x, f₂ x)) x =
id     └────┘        └┘   └┘     
src    └────┘                         
typ    └────┘        └┘   └┘     
doc    └────┘
1271      continuous_linear_map.prod (fderiv 𝕜 f₁ x) (fderiv 𝕜 f₂ x) :=
id       └────────────────────────┘  └────┘  └┘    └────┘  └┘ 
src      └────────────────────────┘  └────┘          └────┘
typ      └────────────────────────┘  └────┘  └┘    └────┘  └┘ 
doc      └────────────────────────┘  └────┘          └────┘
1272  has_fderiv_at.fderiv (has_fderiv_at.prod hf₁.has_fderiv_at hf₂.has_fderiv_at)
id   └──────────────────┘  └────────────────┘ └─┘└────────────┘ └─┘└────────────┘
src  └──────────────────┘  └────────────────┘    └────────────┘    └────────────┘
typ  └──────────────────┘  └────────────────┘ └─┘└────────────┘ └─┘└────────────┘
1273  
1274  lemma differentiable_at.fderiv_within_prod
1275    (hf₁ : differentiable_within_at 𝕜 f₁ s x) (hf₂ : differentiable_within_at 𝕜 f₂ s x)
id            └──────────────────────┘  └┘           └──────────────────────┘  └┘  
src           └──────────────────────┘                  └──────────────────────┘
typ           └──────────────────────┘  └┘           └──────────────────────┘  └┘  
doc           └──────────────────────┘                  └──────────────────────┘
1276    (hxs : unique_diff_within_at 𝕜 s x) :
id            └───────────────────┘   
src           └───────────────────┘
typ           └───────────────────┘   
doc           └───────────────────┘
1277    fderiv_within 𝕜 (λx:E, (f₁ x, f₂ x)) s x =
id     └───────────┘        └┘   └┘      
src    └───────────┘                           
typ    └───────────┘        └┘   └┘      
doc    └───────────┘
1278      continuous_linear_map.prod (fderiv_within 𝕜 f₁ s x) (fderiv_within 𝕜 f₂ s x) :=
id       └────────────────────────┘  └───────────┘  └┘     └───────────┘  └┘  
src      └────────────────────────┘  └───────────┘            └───────────┘
typ      └────────────────────────┘  └───────────┘  └┘     └───────────┘  └┘  
doc      └────────────────────────┘  └───────────┘            └───────────┘
1279  begin
st   └─────
1280    apply has_fderiv_within_at.fderiv_within _ hxs,
id           └────────────────────────────────┘   └─┘
src    └────┘└────────────────────────────────┘└─┘
typ    └────┘└────────────────────────────────┘└─┘└─┘
doc    └────┘                                  └─┘
txt    └────┘                                  └─┘
par    └────┘                                  └─┘
pid                                           └─┘
st   ───────────────────────────────────────────────┘└─
1281    exact has_fderiv_within_at.prod hf₁.has_fderiv_within_at hf₂.has_fderiv_within_at
id           └───────────────────────┘ └──────────────────────┘ └──────────────────────┘
src    └────┘└───────────────────────┘└──────────────────────┘└──────────────────────┘
typ    └────┘└───────────────────────┘└──────────────────────┘└──────────────────────┘
doc    └────┘                                                                         
txt    └────┘                                                                         
par    └────┘                                                                         
pid                                                                                  
st   ───────────────────────────────────────────────────────────────────────────────────┘
1282  end
st   └─┘
1283  
1284  end cartesian_product
1285  
1286  section composition
1287  /-! ###
1288  Derivative of the composition of two functions
1289  
1290  For composition lemmas, we put x explicit to help the elaborator, as otherwise Lean tends to
1291  get confused since there are too many possibilities for composition -/
1292  
1293  variable (x)
1294  
1295  theorem has_fderiv_at_filter.comp {g : F → G} {g' : F →L[𝕜] G}
id                                                      └─┘ 
src                                                        └─┘ 
typ                                                     └─┘ 
doc                                                        └─┘ 
1296    (hg : has_fderiv_at_filter g g' (f x) (L.map f))
id           └──────────────────┘  └┘      └──┘ 
src          └──────────────────┘              └──┘
typ          └──────────────────┘  └┘      └──┘ 
doc          └──────────────────┘              └──┘
1297    (hf : has_fderiv_at_filter f f' x L) :
id           └──────────────────┘  └┘  
src          └──────────────────┘
typ          └──────────────────┘  └┘  
doc          └──────────────────┘
1298    has_fderiv_at_filter (g ∘ f) (g'.comp f') x L :=
id     └──────────────────┘       └┘└───┘ └┘   
src    └──────────────────┘           └───┘
typ    └──────────────────┘       └┘└───┘ └┘   
doc    └──────────────────┘            └───┘
1299  let eq₁ := (g'.is_O_comp _ _).trans_is_o hf in
id       └─┘     └┘└────────┘     └────────┘  └┘
src                └────────┘     └────────┘
typ      └─┘     └┘└────────┘     └────────┘  └┘
1300  let eq₂ := (hg.comp_tendsto tendsto_map).trans_is_O hf.is_O_sub in
id       └─┘     └┘└───────────┘ └─────────┘ └────────┘  └┘└───────┘
src                └───────────┘ └─────────┘ └────────┘    └───────┘
typ      └─┘     └┘└───────────┘ └─────────┘ └────────┘  └┘└───────┘
1301  by { refine eq₂.triangle (eq₁.congr_left (λ x', _)), simp }
id               └──────────┘  └────────────┘
src       └─────┘└──────────┘ └────────────┘  └──────┘  └───┘
typ       └─────┘└──────────┘ └────────────┘  └──────┘  └───┘
doc       └─────┘                             └──────┘  └───┘
txt       └─────┘                             └──────┘  └───┘
par       └─────┘                             └──────┘  └───┘
pid                                          └──────┘      
st     └───────────────────────────────────────────────┘└─────┘└┘
1302  
1303  /- A readable version of the previous theorem,
1304     a general form of the chain rule. -/
1305  
1306  example {g : F → G} {g' : F →L[𝕜] G}
id                            └─┘ 
src                              └─┘ 
typ                           └─┘ 
doc                              └─┘ 
1307    (hg : has_fderiv_at_filter g g' (f x) (L.map f))
id           └──────────────────┘  └┘      └──┘ 
src          └──────────────────┘              └──┘
typ          └──────────────────┘  └┘      └──┘ 
doc          └──────────────────┘              └──┘
1308    (hf : has_fderiv_at_filter f f' x L) :
id           └──────────────────┘  └┘  
src          └──────────────────┘
typ          └──────────────────┘  └┘  
doc          └──────────────────┘
1309    has_fderiv_at_filter (g ∘ f) (g'.comp f') x L :=
id     └──────────────────┘       └┘└───┘ └┘   
src    └──────────────────┘           └───┘
typ    └──────────────────┘       └┘└───┘ └┘   
doc    └──────────────────┘            └───┘
1310  begin
st   └─────
1311    unfold has_fderiv_at_filter at hg,
src    └───────────────────────────────┘
typ    └───────────────────────────────┘
doc    └───────────────────────────────┘
txt    └───────────────────────────────┘
par    └───────────────────────────────┘
pid          └───────────────────┘└────┘
st   ──────────────────────────────────┘└─
1312    have : is_o (λ x', g (f x') - g (f x) - g' (f x' - f x)) (λ x', f x' - f x) L,
id            └──┘                           └┘                                
src    └─────┘└──┘  └───┘     └┘    └┘          └─┘  └───┘      └┘
typ    └─────┘└──┘  └───┘     └┘   └┘ └┘       └─┘  └───┘    └┘
doc    └─────┘└──┘  └───┘     └┘     └┘          └─┘  └───┘      └┘
txt    └─────┘      └───┘     └┘     └┘          └─┘  └───┘      └┘
par    └─────┘      └───┘     └┘     └┘          └─┘  └───┘      └┘
pid    └───┘└┘      └───┘     └┘     └┘          └─┘  └───┘      └┘
st   ──────────────────────────────────────────────────────────────────────────────┘└─
1313      from hg.comp_tendsto (le_refl _),
id            └─────────────┘  └─────┘
src      └───┘└─────────────┘ └─────┘└─┘
typ      └───┘└─────────────┘ └─────┘└─┘
doc      └───┘                       └─┘
txt      └───┘                       └─┘
par      └───┘                       └─┘
pid      └───┘                       └─┘
st   ───────────────────────────────────┘└─
1314    have eq₁ : is_o (λ x', g (f x') - g (f x) - g' (f x' - f x)) (λ x', x' - x) L,
id                └──┘                            └┘                            
src    └─────────┘└──┘  └───┘     └┘     └┘          └─┘  └───┘    └┘
typ    └─────────┘└──┘  └───┘     └┘    └┘ └┘      └─┘  └───┘   └┘
doc    └─────────┘└──┘  └───┘     └┘     └┘          └─┘  └───┘    └┘
txt    └─────────┘      └───┘     └┘     └┘          └─┘  └───┘    └┘
par    └─────────┘      └───┘     └┘     └┘          └─┘  └───┘    └┘
pid    └──────┘└─┘      └───┘     └┘     └┘          └─┘  └───┘    └┘
st   ──────────────────────────────────────────────────────────────────────────────┘└─
1315      from this.trans_is_O hf.is_O_sub,
id            └─────────────┘ └─────────┘
src      └───┘└─────────────┘└─────────┘
typ      └───┘└─────────────┘└─────────┘
doc      └───┘               
txt      └───┘               
par      └───┘               
pid      └───┘               
st   ───────────────────────────────────┘└─
1316    have eq₂ : is_o (λ x', f x' - f x - f' (x' - x)) (λ x', x' - x) L,
id                └──┘                    └┘                         
src    └─────────┘└──┘  └───┘              └─┘  └───┘    └┘
typ    └─────────┘└──┘  └───┘      └┘     └─┘  └───┘   └┘
doc    └─────────┘└──┘  └───┘              └─┘  └───┘    └┘
txt    └─────────┘      └───┘              └─┘  └───┘    └┘
par    └─────────┘      └───┘              └─┘  └───┘    └┘
pid    └──────┘└─┘      └───┘              └─┘  └───┘    └┘
st   ──────────────────────────────────────────────────────────────────┘└─
1317      from hf,
id            └┘
src      └───┘
typ      └───┘└┘
doc      └───┘
txt      └───┘
par      └───┘
pid      └───┘
st   ──────────┘└─
1318    have : is_O
id            └──┘
src    └─────┘└──┘
typ    └─────┘└──┘
doc    └─────┘└──┘
txt    └─────┘    
par    └─────┘    
pid    └───┘└┘    
st   ──────────────
1319      (λ x', g' (f x' - f x - f' (x' - x))) (λ x', f x' - f x - f' (x' - x)) L,
id              └┘                                                └┘          
src  ───┘  └───┘                 └──┘  └───┘              └─┘
typ  ───┘  └───┘└┘               └──┘  └───┘      └┘    └─┘
doc  ───┘  └───┘                 └──┘  └───┘              └─┘
txt  ───┘  └───┘                 └──┘  └───┘              └─┘
par  ───┘  └───┘                 └──┘  └───┘              └─┘
pid  ───┘  └───┘                 └──┘  └───┘              └─┘
st   ───────────────────────────────────────────────────────────────────────────┘└─
1320      from g'.is_O_comp _ _,
src      └───┘              
typ      └───┘              
doc      └───┘              
txt      └───┘              
par      └───┘              
pid      └───┘              
st   ────────┘              
1321    have : is_o (λ x', g' (f x' - f x - f' (x' - x))) (λ x', x' - x) L,
id                    └┘                                   └┘         
typ                   └┘                                   └┘         
1322      from this.trans_is_o eq₂,
1323    have eq₃ : is_o (λ x', g' (f x' - f x) - (g' (f' (x' - x)))) (λ x', x' - x) L,
id                        └┘                                          └┘         
typ                       └┘                                          └┘         
1324      by { refine this.congr_left _, simp},
st                                          └┘
1325    exact eq₁.triangle eq₃
1326  end
st   └─┘
1327  
1328  theorem has_fderiv_within_at.comp {g : F → G} {g' : F →L[𝕜] G} {t : set F}
id                                                                    
src                                                                        
typ                                                                   
1329    (hg : has_fderiv_within_at g g' t (f x)) (hf : has_fderiv_within_at f f' s x) (hst : s ⊆ f ⁻¹' t) :
id                                                                                           
typ                                                                                          
1330    has_fderiv_within_at (g ∘ f) (g'.comp f') s x :=
id                                              
typ                                             
1331  begin
1332    apply has_fderiv_at_filter.comp _ (has_fderiv_at_filter.mono hg _) hf,
1333    calc map f (nhds_within x s)
1334        ≤ nhds_within (f x) (f '' s) : hf.continuous_within_at.tendsto_nhds_within_image
id                                   
typ                                  
1335    ... ≤ nhds_within (f x) t        : nhds_within_mono _ (image_subset_iff.mpr hst)
id                            
typ                           
1336  end
st   └─┘
1337  
1338  /-- The chain rule. -/
1339  theorem has_fderiv_at.comp {g : F → G} {g' : F →L[𝕜] G}
id                                                    
typ                                                   
1340    (hg : has_fderiv_at g g' (f x)) (hf : has_fderiv_at f f' x) :
id                                                          
typ                                                         
1341    has_fderiv_at (g ∘ f) (g'.comp f') x :=
id                                      
typ                                     
1342  (hg.mono hf.continuous_at).comp x hf
id                                   
typ                                  
1343  
1344  theorem has_fderiv_at.comp_has_fderiv_within_at {g : F → G} {g' : F →L[𝕜] G}
id                                                                         
typ                                                                        
1345    (hg : has_fderiv_at g g' (f x)) (hf : has_fderiv_within_at f f' s x) :
id                                                                  
typ                                                                 
1346    has_fderiv_within_at (g ∘ f) (g'.comp f') s x :=
id                                              
typ                                             
1347  begin
1348    rw ← has_fderiv_within_at_univ at hg,
1349    exact has_fderiv_within_at.comp x hg hf subset_preimage_univ
id                                     
typ                                    
1350  end
st   └─┘
1351  
1352  lemma differentiable_within_at.comp {g : F → G} {t : set F}
id                                                        
src                                                         
typ                                                       
1353    (hg : differentiable_within_at 𝕜 g t (f x)) (hf : differentiable_within_at 𝕜 f s x)
id                                                                              
typ                                                                             
1354    (h : s ⊆ f ⁻¹' t) : differentiable_within_at 𝕜 (g ∘ f) s x :=
id                                                        
typ                                                       
1355  begin
1356    rcases hf with ⟨f', hf'⟩,
1357    rcases hg with ⟨g', hg'⟩,
1358    exact ⟨continuous_linear_map.comp g' f', hg'.comp x hf' h⟩
id                                                       
typ                                                      
1359  end
st   └─┘
1360  
1361  lemma differentiable_at.comp {g : F → G}
id                                        
typ                                       
1362    (hg : differentiable_at 𝕜 g (f x)) (hf : differentiable_at 𝕜 f x) :
id                                                              
typ                                                             
1363    differentiable_at 𝕜 (g ∘ f) x :=
id                              
typ                             
1364  (hg.has_fderiv_at.comp x hf.has_fderiv_at).differentiable_at
id                          
typ                         
1365  
1366  lemma fderiv_within.comp {g : F → G} {t : set F}
id                                             
src                                              
typ                                            
1367    (hg : differentiable_within_at 𝕜 g t (f x)) (hf : differentiable_within_at 𝕜 f s x)
id                                                                              
typ                                                                             
1368    (h : s ⊆ f ⁻¹' t) (hxs : unique_diff_within_at 𝕜 s x) :
id                                                    
typ                                                   
1369    fderiv_within 𝕜 (g ∘ f) s x =
id                           
typ                          
1370      continuous_linear_map.comp (fderiv_within 𝕜 g t (f x)) (fderiv_within 𝕜 f s x) :=
id                                                                           
typ                                                                          
1371  begin
1372    apply has_fderiv_within_at.fderiv_within _ hxs,
1373    exact has_fderiv_within_at.comp x (hg.has_fderiv_within_at) (hf.has_fderiv_within_at) h
id                                     
typ                                    
1374  end
st   └─┘
1375  
1376  lemma fderiv.comp {g : F → G}
id                             
typ                            
1377    (hg : differentiable_at 𝕜 g (f x)) (hf : differentiable_at 𝕜 f x) :
id                                                              
typ                                                             
1378    fderiv 𝕜 (g ∘ f) x = continuous_linear_map.comp (fderiv 𝕜 g (f x)) (fderiv 𝕜 f x) :=
id                                                                          
typ                                                                         
1379  begin
1380    apply has_fderiv_at.fderiv,
1381    exact has_fderiv_at.comp x hg.has_fderiv_at hf.has_fderiv_at
id                              
typ                             
1382  end
st   └─┘
1383  
1384  lemma differentiable_on.comp {g : F → G} {t : set F}
id                                                 
src                                                  
typ                                                
1385    (hg : differentiable_on 𝕜 g t) (hf : differentiable_on 𝕜 f s) (st : s ⊆ f ⁻¹' t) :
id                                                                           
typ                                                                          
1386    differentiable_on 𝕜 (g ∘ f) s :=
id                              
typ                             
1387  λx hx, differentiable_within_at.comp x (hg (f x) (st hx)) (hf x hx) st
id                                                             
typ                                                            
1388  
1389  lemma differentiable.comp {g : F → G} (hg : differentiable 𝕜 g) (hf : differentiable 𝕜 f) :
id                                                                                     
typ                                                                                    
1390    differentiable 𝕜 (g ∘ f) :=
id                         
typ                        
1391  λx, differentiable_at.comp x (hg (f x)) (hf x)
id                                           
typ                                          
1392  
1393  end composition
1394  
1395  section smul
1396  /-! ### Derivative of the product of a scalar-valued function and a vector-valued function -/
1397  
1398  variables {c : E → 𝕜} {c' : E →L[𝕜] 𝕜}
1399  
1400  theorem has_fderiv_within_at.smul
1401    (hc : has_fderiv_within_at c c' s x) (hf : has_fderiv_within_at f f' s x) :
id                                                                       
typ                                                                      
1402    has_fderiv_within_at (λ y, c y • f y) (c x • f' + c'.smul_right (f x)) s x :=
id                                                                    
typ                                                                   
1403  begin
1404    have : is_bounded_bilinear_map 𝕜 (λ (p : 𝕜 × F), p.1 • p.2) := is_bounded_bilinear_map_smul,
id                                                 
typ                                                
1405    exact has_fderiv_at.comp_has_fderiv_within_at x (this.has_fderiv_at (c x, f x)) (hc.prod hf)
id                                                                               
typ                                                                              
1406  end
st   └─┘
1407  
1408  theorem has_fderiv_at.smul (hc : has_fderiv_at c c' x) (hf : has_fderiv_at f f' x) :
id                                                                                
typ                                                                               
1409    has_fderiv_at (λ y, c y • f y) (c x • f' + c'.smul_right (f x)) x :=
id                                                            
typ                                                           
1410  begin
1411    have : is_bounded_bilinear_map 𝕜 (λ (p : 𝕜 × F), p.1 • p.2) := is_bounded_bilinear_map_smul,
id                                                 
typ                                                
1412    exact has_fderiv_at.comp x (this.has_fderiv_at (c x, f x)) (hc.prod hf)
id                                                          
typ                                                         
1413  end
st   └─┘
1414  
1415  lemma differentiable_within_at.smul
1416    (hc : differentiable_within_at 𝕜 c s x) (hf : differentiable_within_at 𝕜 f s x) :
id                                                                           
typ                                                                          
1417    differentiable_within_at 𝕜 (λ y, c y • f y) s x :=
id                                            
typ                                           
1418  (hc.has_fderiv_within_at.smul hf.has_fderiv_within_at).differentiable_within_at
1419  
1420  lemma differentiable_at.smul (hc : differentiable_at 𝕜 c x) (hf : differentiable_at 𝕜 f x) :
id                                                                                      
typ                                                                                     
1421    differentiable_at 𝕜 (λ y, c y • f y) x :=
id                                    
typ                                   
1422  (hc.has_fderiv_at.smul hf.has_fderiv_at).differentiable_at
1423  
1424  lemma differentiable_on.smul (hc : differentiable_on 𝕜 c s) (hf : differentiable_on 𝕜 f s) :
id                                                                                      
typ                                                                                     
1425    differentiable_on 𝕜 (λ y, c y • f y) s :=
id                                    
typ                                   
1426  λx hx, (hc x hx).smul (hf x hx)
id                           
typ                          
1427  
1428  lemma differentiable.smul (hc : differentiable 𝕜 c) (hf : differentiable 𝕜 f) :
id                                                                           
typ                                                                          
1429    differentiable 𝕜 (λ y, c y • f y) :=
id                               
typ                              
1430  λx, (hc x).smul (hf x)
id                     
typ                    
1431  
1432  lemma fderiv_within_smul (hxs : unique_diff_within_at 𝕜 s x)
id                                                           
typ                                                          
1433    (hc : differentiable_within_at 𝕜 c s x) (hf : differentiable_within_at 𝕜 f s x) :
id                                                                           
typ                                                                          
1434    fderiv_within 𝕜 (λ y, c y • f y) s x =
id                                 
typ                                
1435      c x • fderiv_within 𝕜 f s x + (fderiv_within 𝕜 c s x).smul_right (f x) :=
id                                                                  
typ                                                                 
1436  (hc.has_fderiv_within_at.smul hf.has_fderiv_within_at).fderiv_within hxs
1437  
1438  lemma fderiv_smul (hc : differentiable_at 𝕜 c x) (hf : differentiable_at 𝕜 f x) :
id                                                                           
typ                                                                          
1439    fderiv 𝕜 (λ y, c y • f y) x =
id                         
typ                        
1440      c x • fderiv 𝕜 f x + (fderiv 𝕜 c x).smul_right (f x) :=
id                                                
typ                                               
1441  (hc.has_fderiv_at.smul hf.has_fderiv_at).fderiv
1442  
1443  theorem has_fderiv_within_at.smul_const (hc : has_fderiv_within_at c c' s x) (f : F) :
id                                                                                  
typ                                                                                 
1444    has_fderiv_within_at (λ y, c y • f) (c'.smul_right f) s x :=
id                                                       
typ                                                      
1445  begin
1446    convert hc.smul (has_fderiv_within_at_const f x s),
id                                                   
typ                                                  
1447    -- Help Lean find an instance
1448    letI : distrib_mul_action 𝕜 (E →L[𝕜] F) :=
id                                        
typ                                       
1449      continuous_linear_map.module.to_distrib_mul_action,
1450    rw [smul_zero, zero_add]
st                            
1451  end
st   └─┘
1452  
1453  theorem has_fderiv_at.smul_const (hc : has_fderiv_at c c' x) (f : F) :
id                                                                   
typ                                                                  
1454    has_fderiv_at (λ y, c y • f) (c'.smul_right f) x :=
id                                               
typ                                              
1455  begin
1456    rw [← has_fderiv_within_at_univ] at *,
1457    exact hc.smul_const f
id                         
typ                        
1458  end
st   └─┘
1459  
1460  lemma differentiable_within_at.smul_const
1461    (hc : differentiable_within_at 𝕜 c s x) (f : F) :
id                                              
typ                                             
1462    differentiable_within_at 𝕜 (λ y, c y • f) s x :=
id                                           
typ                                          
1463  (hc.has_fderiv_within_at.smul_const f).differentiable_within_at
id                                       
typ                                      
1464  
1465  lemma differentiable_at.smul_const (hc : differentiable_at 𝕜 c x) (f : F) :
id                                                                       
typ                                                                      
1466    differentiable_at 𝕜 (λ y, c y • f) x :=
id                                   
typ                                  
1467  (hc.has_fderiv_at.smul_const f).differentiable_at
id                                
typ                               
1468  
1469  lemma differentiable_on.smul_const (hc : differentiable_on 𝕜 c s) (f : F) :
id                                                                       
typ                                                                      
1470    differentiable_on 𝕜 (λ y, c y • f) s :=
id                                   
typ                                  
1471  λx hx, (hc x hx).smul_const f
id                             
typ                            
1472  
1473  lemma differentiable.smul_const (hc : differentiable 𝕜 c) (f : F) :
id                                                                
typ                                                               
1474    differentiable 𝕜 (λ y, c y • f) :=
id                              
typ                             
1475  λx, (hc x).smul_const f
id                       
typ                      
1476  
1477  lemma fderiv_within_smul_const (hxs : unique_diff_within_at 𝕜 s x)
id                                                                 
typ                                                                
1478    (hc : differentiable_within_at 𝕜 c s x) (f : F) :
id                                              
typ                                             
1479    fderiv_within 𝕜 (λ y, c y • f) s x =
id                                
typ                               
1480      (fderiv_within 𝕜 c s x).smul_right f :=
id                                      
typ                                     
1481  (hc.has_fderiv_within_at.smul_const f).fderiv_within hxs
id                                       
typ                                      
1482  
1483  lemma fderiv_smul_const (hc : differentiable_at 𝕜 c x) (f : F) :
id                                                            
typ                                                           
1484    fderiv 𝕜 (λ y, c y • f) x = (fderiv 𝕜 c x).smul_right f :=
id                                                  
typ                                                 
1485  (hc.has_fderiv_at.smul_const f).fderiv
id                                
typ                               
1486  
1487  end smul
1488  
1489  section mul
1490  /-! ### Derivative of the product of two scalar-valued functions -/
1491  
1492  set_option class.instance_max_depth 120
doc             └──────────────────────┘
1493  variables {c d : E → 𝕜} {c' d' : E →L[𝕜] 𝕜}
1494  
1495  theorem has_fderiv_within_at.mul
1496    (hc : has_fderiv_within_at c c' s x) (hd : has_fderiv_within_at d d' s x) :
id                                                                       
typ                                                                      
1497    has_fderiv_within_at (λ y, c y * d y) (c x • d' + d x • c') s x :=
id                                                          
typ                                                         
1498  begin
1499    have : is_bounded_bilinear_map 𝕜 (λ (p : 𝕜 × 𝕜), p.1 * p.2) := is_bounded_bilinear_map_mul,
id                                                  
typ                                                 
1500    convert has_fderiv_at.comp_has_fderiv_within_at x (this.has_fderiv_at (c x, d x)) (hc.prod hd),
id                                                                                 
typ                                                                                
1501    ext z,
1502    change c x * d' z + d x * c' z = c x * d' z + c' z * d x,
id                                                         
typ                                                        
1503    ring
1504  end
st   └─┘
1505  
1506  theorem has_fderiv_at.mul (hc : has_fderiv_at c c' x) (hd : has_fderiv_at d d' x) :
id                                                                               
typ                                                                              
1507    has_fderiv_at (λ y, c y * d y) (c x • d' + d x • c') x :=
id                                                  
typ                                                 
1508  begin
1509    have : is_bounded_bilinear_map 𝕜 (λ (p : 𝕜 × 𝕜), p.1 * p.2) := is_bounded_bilinear_map_mul,
id                                                  
typ                                                 
1510    convert has_fderiv_at.comp x (this.has_fderiv_at (c x, d x)) (hc.prod hd),
id                                                            
typ                                                           
1511    ext z,
1512    change c x * d' z + d x * c' z = c x * d' z + c' z * d x,
id                                                         
typ                                                        
1513    ring
1514  end
st   └─┘
1515  
1516  lemma differentiable_within_at.mul
1517    (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) :
id                                                                           
typ                                                                          
1518    differentiable_within_at 𝕜 (λ y, c y * d y) s x :=
id                                            
typ                                           
1519  (hc.has_fderiv_within_at.mul hd.has_fderiv_within_at).differentiable_within_at
1520  
1521  lemma differentiable_at.mul (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) :
id                                                                                     
typ                                                                                    
1522    differentiable_at 𝕜 (λ y, c y * d y) x :=
id                                    
typ                                   
1523  (hc.has_fderiv_at.mul hd.has_fderiv_at).differentiable_at
1524  
1525  lemma differentiable_on.mul (hc : differentiable_on 𝕜 c s) (hd : differentiable_on 𝕜 d s) :
id                                                                                     
typ                                                                                    
1526    differentiable_on 𝕜 (λ y, c y * d y) s :=
id                                    
typ                                   
1527  λx hx, (hc x hx).mul (hd x hx)
id                           
typ                          
1528  
1529  lemma differentiable.mul (hc : differentiable 𝕜 c) (hd : differentiable 𝕜 d) :
id                                                                          
typ                                                                         
1530    differentiable 𝕜 (λ y, c y * d y) :=
id                               
typ                              
1531  λx, (hc x).mul (hd x)
id                    
typ                   
1532  
1533  lemma fderiv_within_mul (hxs : unique_diff_within_at 𝕜 s x)
id                                                          
typ                                                         
1534    (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) :
id                                                                           
typ                                                                          
1535    fderiv_within 𝕜 (λ y, c y * d y) s x =
id                                 
typ                                
1536      c x • fderiv_within 𝕜 d s x + d x • fderiv_within 𝕜 c s x :=
id                                                     
typ                                                    
1537  (hc.has_fderiv_within_at.mul hd.has_fderiv_within_at).fderiv_within hxs
1538  
1539  lemma fderiv_mul (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) :
id                                                                          
typ                                                                         
1540    fderiv 𝕜 (λ y, c y * d y) x =
id                         
typ                        
1541      c x • fderiv 𝕜 d x + d x • fderiv 𝕜 c x :=
id                                    
typ                                   
1542  (hc.has_fderiv_at.mul hd.has_fderiv_at).fderiv
1543  
1544  theorem has_fderiv_within_at.mul_const
1545    (hc : has_fderiv_within_at c c' s x) (d : 𝕜) :
id                                            
typ                                           
1546    has_fderiv_within_at (λ y, c y * d) (d • c') s x :=
id                                              
typ                                             
1547  begin
1548    have := hc.mul (has_fderiv_within_at_const d x s),
id                                                  
typ                                                 
1549    letI : distrib_mul_action 𝕜 (E →L[𝕜] 𝕜) := continuous_linear_map.module.to_distrib_mul_action,
id                                         
typ                                        
1550    rwa [smul_zero, zero_add] at this
1551  end
st   └─┘
1552  
1553  theorem has_fderiv_at.mul_const (hc : has_fderiv_at c c' x) (d : 𝕜) :
id                                                                  
typ                                                                 
1554    has_fderiv_at (λ y, c y * d) (d • c') x :=
id                                      
typ                                     
1555  begin
1556    rw [← has_fderiv_within_at_univ] at *,
1557    exact hc.mul_const d
id                        
typ                       
1558  end
st   └─┘
1559  
1560  lemma differentiable_within_at.mul_const
1561    (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜) :
id                                              
typ                                             
1562    differentiable_within_at 𝕜 (λ y, c y * d) s x :=
id                                           
typ                                          
1563  (hc.has_fderiv_within_at.mul_const d).differentiable_within_at
id                                      
typ                                     
1564  
1565  lemma differentiable_at.mul_const (hc : differentiable_at 𝕜 c x) (d : 𝕜) :
id                                                                      
typ                                                                     
1566    differentiable_at 𝕜 (λ y, c y * d) x :=
id                                   
typ                                  
1567  (hc.has_fderiv_at.mul_const d).differentiable_at
id                               
typ                              
1568  
1569  lemma differentiable_on.mul_const (hc : differentiable_on 𝕜 c s) (d : 𝕜) :
id                                                                      
typ                                                                     
1570    differentiable_on 𝕜 (λ y, c y * d) s :=
id                                   
typ                                  
1571  λx hx, (hc x hx).mul_const d
id                            
typ                           
1572  
1573  lemma differentiable.mul_const (hc : differentiable 𝕜 c) (d : 𝕜) :
id                                                               
typ                                                              
1574    differentiable 𝕜 (λ y, c y * d) :=
id                              
typ                             
1575  λx, (hc x).mul_const d
id                      
typ                     
1576  
1577  lemma fderiv_within_mul_const (hxs : unique_diff_within_at 𝕜 s x)
id                                                                
typ                                                               
1578    (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜) :
id                                              
typ                                             
1579    fderiv_within 𝕜 (λ y, c y * d) s x = d • fderiv_within 𝕜 c s x :=
id                                                       
typ                                                      
1580  (hc.has_fderiv_within_at.mul_const d).fderiv_within hxs
id                                      
typ                                     
1581  
1582  lemma fderiv_mul_const (hc : differentiable_at 𝕜 c x) (d : 𝕜) :
id                                                           
typ                                                          
1583    fderiv 𝕜 (λ y, c y * d) x = d • fderiv 𝕜 c x :=
id                                       
typ                                      
1584  (hc.has_fderiv_at.mul_const d).fderiv
id                               
typ                              
1585  
1586  theorem has_fderiv_within_at.const_mul
1587    (hc : has_fderiv_within_at c c' s x) (d : 𝕜) :
id                                            
typ                                           
1588    has_fderiv_within_at (λ y, d * c y) (d • c') s x :=
id                                              
typ                                             
1589  begin
1590    simp only [mul_comm d],
id                         
typ                        
1591    exact hc.mul_const d,
id                        
typ                       
1592  end
st   └─┘
1593  
1594  theorem has_fderiv_at.const_mul (hc : has_fderiv_at c c' x) (d : 𝕜) :
id                                                                  
typ                                                                 
1595    has_fderiv_at (λ y, d * c y) (d • c') x :=
id                                      
typ                                     
1596  begin
1597    simp only [mul_comm d],
id                         
typ                        
1598    exact hc.mul_const d,
id                        
typ                       
1599  end
st   └─┘
1600  
1601  lemma differentiable_within_at.const_mul
1602    (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜) :
id                                              
typ                                             
1603    differentiable_within_at 𝕜 (λ y, d * c y) s x :=
id                                           
typ                                          
1604  (hc.has_fderiv_within_at.const_mul d).differentiable_within_at
id                                      
typ                                     
1605  
1606  lemma differentiable_at.const_mul (hc : differentiable_at 𝕜 c x) (d : 𝕜) :
id                                                                      
typ                                                                     
1607    differentiable_at 𝕜 (λ y, d * c y) x :=
id                                   
typ                                  
1608  (hc.has_fderiv_at.const_mul d).differentiable_at
id                               
typ                              
1609  
1610  lemma differentiable_on.const_mul (hc : differentiable_on 𝕜 c s) (d : 𝕜) :
id                                                                      
typ                                                                     
1611    differentiable_on 𝕜 (λ y, d * c y) s :=
id                                   
typ                                  
1612  λx hx, (hc x hx).const_mul d
id                            
typ                           
1613  
1614  lemma differentiable.const_mul (hc : differentiable 𝕜 c) (d : 𝕜) :
id                                                               
typ                                                              
1615    differentiable 𝕜 (λ y, d * c y) :=
id                              
typ                             
1616  λx, (hc x).const_mul d
id                      
typ                     
1617  
1618  lemma fderiv_within_const_mul (hxs : unique_diff_within_at 𝕜 s x)
id                                                                
typ                                                               
1619    (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜) :
id                                              
typ                                             
1620    fderiv_within 𝕜 (λ y, d * c y) s x = d • fderiv_within 𝕜 c s x :=
id                                                       
typ                                                      
1621  (hc.has_fderiv_within_at.const_mul d).fderiv_within hxs
id                                      
typ                                     
1622  
1623  lemma fderiv_const_mul (hc : differentiable_at 𝕜 c x) (d : 𝕜) :
id                                                           
typ                                                          
1624    fderiv 𝕜 (λ y, d * c y) x = d • fderiv 𝕜 c x :=
id                                       
typ                                      
1625  (hc.has_fderiv_at.const_mul d).fderiv
id                               
typ                              
1626  
1627  end mul
1628  
1629  end
1630  
1631  section
1632  /-
1633    In the special case of a normed space over the reals,
1634    we can use  scalar multiplication in the `tendsto` characterization
1635    of the Fréchet derivative.
1636  -/
1637  
1638  
1639  variables {E : Type*} [normed_group E] [normed_space ℝ E]
id                          └──────────┘     └──────────┘ 
src                         └──────────┘     └──────────┘ 
typ                         └──────────┘     └──────────┘ 
doc                         └──────────┘     └──────────┘
1640  variables {F : Type*} [normed_group F] [normed_space ℝ F]
id                          └──────────┘     └──────────┘ 
src                         └──────────┘     └──────────┘ 
typ                         └──────────┘     └──────────┘ 
doc                         └──────────┘     └──────────┘
1641  variables {f : E → F} {f' : E →L[ℝ] F} {x : E}
id                                 └─┘
src                                └─┘
typ                                └─┘
doc                                └─┘ 
1642  
1643  theorem has_fderiv_at_filter_real_equiv {L : filter E} :
id                                                └────┘ 
src                                               └────┘
typ                                               └────┘ 
1644    tendsto (λ x' : E, ∥x' - x∥⁻¹ * ∥f x' - f x - f' (x' - x)∥) L (𝓝 0) ↔
id     └─────┘           └┘  └┘   └┘     └┘  └┘           
src    └─────┘                 └┘                                
typ    └─────┘           └┘  └┘   └┘     └┘  └┘           
doc    └─────┘                                                        
1645    tendsto (λ x' : E, ∥x' - x∥⁻¹ • (f x' - f x - f' (x' - x))) L (𝓝 0) :=
id     └─────┘           └┘  └┘    └┘     └┘  └┘        
src    └─────┘                 └┘                              
typ    └─────┘           └┘  └┘    └┘     └┘  └┘        
doc    └─────┘                                                        
1646  begin
1647    symmetry,
1648    rw [tendsto_iff_norm_tendsto_zero], refine tendsto_congr (λ x', _),
id                                                                 └┘
typ                                                                └┘
1649    have : ∥x' + -x∥⁻¹ ≥ 0, from inv_nonneg.mpr (norm_nonneg _),
id             └┘    
typ            └┘    
1650    simp [norm_smul, real.norm_eq_abs, abs_of_nonneg this]
1651  end
st   └─┘
1652  
1653  lemma has_fderiv_at.lim_real (hf : has_fderiv_at f f' x) (v : E) :
id                                                               
typ                                                              
1654    tendsto (λ (c:ℝ), c • (f (x + c⁻¹ • v) - f x)) at_top (𝓝 (f' v)) :=
id                                                          
src                  
typ                                                         
1655  begin
1656    apply hf.lim v,
1657    rw tendsto_at_top_at_top,
1658    exact λ b, ⟨b, λ a ha, le_trans ha (le_abs_self _)⟩
id                     
typ                    
1659  end
st   └─┘
1660  
1661  end
1662  
1663  section tangent_cone
1664  
1665  variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
id                          └──────────────────────┘
src                         └──────────────────────┘
typ                         └──────────────────────┘
doc                         └──────────────────────┘
1666  {E : Type*} [normed_group E] [normed_space 𝕜 E]
id               └──────────┘     └──────────┘
src               └──────────┘     └──────────┘
typ              └──────────┘     └──────────┘
doc               └──────────┘     └──────────┘
1667  {F : Type*} [normed_group F] [normed_space 𝕜 F]
id                └──────────┘     └──────────┘
src               └──────────┘     └──────────┘
typ               └──────────┘     └──────────┘
doc               └──────────┘     └──────────┘
1668  {f : E → F} {s : set E} {f' : E →L[𝕜] F}
id                    └─┘            └─┘ 
src                   └─┘            └─┘ 
typ                   └─┘            └─┘ 
doc                                  └─┘ 
1669  
1670  /-- The image of a tangent cone under the differential of a map is included in the tangent cone to
1671  the image. -/
1672  lemma has_fderiv_within_at.image_tangent_cone_subset {x : E} (h : has_fderiv_within_at f f' s x) :
id                                                                    └──────────────────┘  └┘  
src                                                                    └──────────────────┘
typ                                                                   └──────────────────┘  └┘  
doc                                                                    └──────────────────┘
1673    f' '' (tangent_cone_at 𝕜 s x) ⊆ tangent_cone_at 𝕜 (f '' s) (f x) :=
id     └┘ └┘  └─────────────┘      └─────────────┘    └┘     
src       └┘  └─────────────┘         └─────────────┘      └┘
typ    └┘ └┘  └─────────────┘      └─────────────┘    └┘     
doc           └─────────────┘          └─────────────┘
1674  begin
st    └──┘
1675    rw image_subset_iff,
1676    rintros v ⟨c, d, dtop, clim, cdlim⟩,
1677    refine ⟨c, (λn, f (x + d n) - f x), mem_sets_of_superset dtop _, clim, h.lim at_top dtop clim cdlim⟩,
id                                 
typ                                
1678    simp [-mem_image, mem_image_of_mem] {contextual := tt}
id                                                        └┘
src                                                       └┘
typ                                                       └┘
1679  end
st   └─┘
1680  
1681  /-- If a set has the unique differentiability property at a point x, then the image of this set
1682  under a map with onto derivative has also the unique differentiability property at the image point.
1683  -/
1684  lemma has_fderiv_within_at.unique_diff_within_at {x : E} (h : has_fderiv_within_at f f' s x)
id                                                                                          
typ                                                                                         
1685    (hs : unique_diff_within_at 𝕜 s x) (h' : closure (range f') = univ) :
id                                   
typ                                  
1686    unique_diff_within_at 𝕜 (f '' s) (f x) :=
id                                     
typ                                    
1687  begin
1688    have A : ∀v ∈ tangent_cone_at 𝕜 s x, f' v ∈ tangent_cone_at 𝕜 (f '' s) (f x),
id                                                                            
typ                                                                           
1689    { assume v hv,
1690      have := h.image_tangent_cone_subset,
1691      rw image_subset_iff at this,
1692      exact this hv },
st                     └┘
1693    have B : ∀v ∈ (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E),
id                                                                   
typ                                                                  
1694      f' v ∈ (submodule.span 𝕜 (tangent_cone_at 𝕜 (f '' s) (f x)) : set F),
id                                                                 └─┘ 
src                                                                    └─┘
typ                                                                └─┘ 
1695    { assume v hv,
1696      apply submodule.span_induction hv,
1697      { exact λ w hw, submodule.subset_span (A w hw) },
id                 
typ                
st                                                      └┘
1698      { simp },
st              └┘
1699      { assume w₁ w₂ hw₁ hw₂,
1700        rw continuous_linear_map.map_add,
1701        exact submodule.add_mem (submodule.span 𝕜 (tangent_cone_at 𝕜 (f '' s) (f x))) hw₁ hw₂ },
id                                                                               
typ                                                                              
st                                                                                               └┘
1702      { assume a w hw,
1703        rw continuous_linear_map.map_smul,
1704        exact submodule.smul_mem (submodule.span 𝕜 (tangent_cone_at 𝕜 (f '' s) (f x))) _ hw } },
id                                                                                
typ                                                                               
st                                                                                             └──┘
1705    rw [unique_diff_within_at, ← univ_subset_iff],
1706    split,
1707    show f x ∈ closure (f '' s), from h.continuous_within_at.mem_closure_image hs.2,
id                             
typ                            
1708    show univ ⊆ closure ↑(submodule.span 𝕜 (tangent_cone_at 𝕜 (f '' s) (f x))), from calc
id                                                                        
typ                                                                       
1709      univ ⊆ closure (range f') : univ_subset_iff.2 h'
1710      ... = closure (f' '' univ) : by rw image_univ
1711      ... = closure (f' '' (closure (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E))) : by rw hs.1
id                                                                                    
typ                                                                                   
1712      ... ⊆ closure (closure (f' '' (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E))) :
1713        closure_mono (image_closure_subset_closure_image f'.cont)
1714      ... = closure (f' '' (submodule.span 𝕜 (tangent_cone_at 𝕜 s x) : set E)) : closure_closure
1715      ... ⊆ closure (submodule.span 𝕜 (tangent_cone_at 𝕜 (f '' s) (f x)) : set F) :
id                                                                               
typ                                                                              
1716        closure_mono (image_subset_iff.mpr B)
1717  end
st   └─┘
1718  
1719  lemma has_fderiv_within_at.unique_diff_within_at_of_continuous_linear_equiv
1720    {x : E} (e' : E ≃L[𝕜] F) (h : has_fderiv_within_at f (e' : E →L[𝕜] F) s x)
id                                                                    
typ                                                                   
1721    (hs : unique_diff_within_at 𝕜 s x) :
id                                   
typ                                  
1722    unique_diff_within_at 𝕜 (f '' s) (f x) :=
id                                     
typ                                    
1723  begin
1724    apply h.unique_diff_within_at hs,
1725    have : range (e' : E →L[𝕜] F) = univ := e'.to_linear_equiv.to_equiv.range_eq_univ,
id                              
typ                             
1726    rw [this, closure_univ]
st                           
1727  end
st   └─┘
1728  
1729  end tangent_cone
1730  
1731  section restrict_scalars
1732  /-! ### Restricting from `ℂ` to `ℝ`, or generally from `𝕜'` to `𝕜`
1733  
1734  If a function is differentiable over `ℂ`, then it is differentiable over `ℝ`. In this paragraph,
1735  we give variants of this statement, in the general situation where `ℂ` and `ℝ` are replaced
1736  respectively by `𝕜'` and `𝕜` where `𝕜'` is a normed algebra over `𝕜`. -/
1737  
1738  variables (𝕜 : Type*) [nondiscrete_normed_field 𝕜]
id                            └──┘  └──┘  └──┘  └──┘
src                           └──┘  └──┘  └──┘  └──┘
typ                           └──┘  └──┘  └──┘  └──┘
doc                           └──┘  └──┘  └──┘  └──┘
1739  {𝕜' : Type*} [nondiscrete_normed_field 𝕜'] [normed_algebra 𝕜 𝕜']
id                 └──┘  └──┘  └──┘  └──┘
src                └──┘  └──┘  └──┘  └──┘
typ                └──┘  └──┘  └──┘  └──┘
doc                └──┘  └──┘  └──┘  └──┘
1740  {E : Type*} [normed_group E] [normed_space 𝕜' E]
id                └──────────┘
src               └──────────┘
typ               └──────────┘
doc               └──────────┘
1741  {F : Type*} [normed_group F] [normed_space 𝕜' F]
id                └──────────┘
src               └──────────┘
typ               └──────────┘
doc               └──────────┘
1742  {f : E → F} {f' : E →L[𝕜'] F} {s : set E} {x : E}
id                                      └─┘
src                                     └─┘
typ                                     └─┘
1743  
1744  local attribute [instance] normed_space.restrict_scalars
1745  
1746  lemma has_fderiv_at.restrict_scalars (h : has_fderiv_at f f' x) :
id                                                               
typ                                                              
1747    has_fderiv_at f (f'.restrict_scalars 𝕜) x := h
id                                           
typ                                          
1748  
1749  lemma has_fderiv_within_at.restrict_scalars (h : has_fderiv_within_at f f' s x) :
id                                                                              
typ                                                                             
1750    has_fderiv_within_at f (f'.restrict_scalars 𝕜) s x := h
id                                                   
typ                                                  
1751  
1752  lemma differentiable_at.restrict_scalars (h : differentiable_at 𝕜' f x) :
id                                                                   └┘  
typ                                                                  └┘  
1753    differentiable_at 𝕜 f x :=
id                         
typ                        
1754  (h.has_fderiv_at.restrict_scalars 𝕜).differentiable_at
id                                     
typ                                    
1755  
1756  lemma differentiable_within_at.restrict_scalars (h : differentiable_within_at 𝕜' f s x) :
id                                                                                 └┘   
typ                                                                                └┘   
1757    differentiable_within_at 𝕜 f s x :=
id                                 
typ                                
1758  (h.has_fderiv_within_at.restrict_scalars 𝕜).differentiable_within_at
id                                            
typ                                           
1759  
1760  lemma differentiable_on.restrict_scalars (h : differentiable_on 𝕜' f s) :
id                                                                   └┘  
typ                                                                  └┘  
1761    differentiable_on 𝕜 f s :=
id                         
typ                        
1762  λx hx, (h x hx).restrict_scalars 𝕜
id                                  
typ                                 
1763  
1764  lemma differentiable.restrict_scalars (h : differentiable 𝕜' f) :
id                                                             └┘ 
typ                                                            └┘ 
1765    differentiable 𝕜 f :=
id                     
typ                    
1766  λx, (h x).restrict_scalars 𝕜
id                            
typ                           
1767  
1768  end restrict_scalars